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
43
// is non residue ?
t0 := addmod(mulmod(t0, t0, N), mulmod(t1, t1, N), N) let freemem := mload(0x40) mstore(freemem, 0x20) mstore(add(freemem, 0x20), 0x20) mstore(add(freemem, 0x40), 0x20) mstore(add(freemem, 0x60), t0)
t0 := addmod(mulmod(t0, t0, N), mulmod(t1, t1, N), N) let freemem := mload(0x40) mstore(freemem, 0x20) mstore(add(freemem, 0x20), 0x20) mstore(add(freemem, 0x40), 0x20) mstore(add(freemem, 0x60), t0)
18,570
208
// make sure they own the name
require(plyrNames_[_pID][_name] == true, "umm... thats not a name you own");
require(plyrNames_[_pID][_name] == true, "umm... thats not a name you own");
35,176
131
// If none of the above conditions are satisfied, then should not rebalance
return ShouldRebalance.NONE;
return ShouldRebalance.NONE;
34,745
117
// This means the controller will withdraw tokens to keep price So they need to redeem PCTokens
deltaWeight = BalancerSafeMath.bsub(currentWeight, newWeight);
deltaWeight = BalancerSafeMath.bsub(currentWeight, newWeight);
33,520
161
// See {ERC20-_mint}. /
function swapFromNeo(address to, string memory from, uint256 amount, uint256 swapId) public virtual { require(hasRole(MINTER_ROLE, msg.sender), "[NEX] Caller is not a minter"); require(_swapsFromNeo[swapId] == false, "[NEX] Swap for given swap id already performed"); _mint(to, amount); _swapsFromNeo[swapId] = true; emit SwapFromNeo(to, from, amount, swapId); }
function swapFromNeo(address to, string memory from, uint256 amount, uint256 swapId) public virtual { require(hasRole(MINTER_ROLE, msg.sender), "[NEX] Caller is not a minter"); require(_swapsFromNeo[swapId] == false, "[NEX] Swap for given swap id already performed"); _mint(to, amount); _swapsFromNeo[swapId] = true; emit SwapFromNeo(to, from, amount, swapId); }
31,938
144
// calculate amount of BTRFLY available for claim by depositor_depositor address return pendingPayout_ uint /
function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) { uint percentVested = percentVestedFor( _depositor ); uint payout = bondInfo[ _depositor ].payout; if ( percentVested >= 10000 ) { pendingPayout_ = payout; } else { pendingPayout_ = payout.mul( percentVested ).div( 10000 ); } }
function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) { uint percentVested = percentVestedFor( _depositor ); uint payout = bondInfo[ _depositor ].payout; if ( percentVested >= 10000 ) { pendingPayout_ = payout; } else { pendingPayout_ = payout.mul( percentVested ).div( 10000 ); } }
14,167
92
// close the locked position after withdrawing all the reward
if (!_setupsInfo[_setups[farmingPosition.setupIndex].infoIndex].free) { _setupPositionsCount[farmingPosition.setupIndex] -= 1; if (_setupPositionsCount[farmingPosition.setupIndex] == 0 && !_setups[farmingPosition.setupIndex].active) { _giveBack(_rewardReceived[farmingPosition.setupIndex] - _rewardPaid[farmingPosition.setupIndex]); delete _setups[farmingPosition.setupIndex]; }
if (!_setupsInfo[_setups[farmingPosition.setupIndex].infoIndex].free) { _setupPositionsCount[farmingPosition.setupIndex] -= 1; if (_setupPositionsCount[farmingPosition.setupIndex] == 0 && !_setups[farmingPosition.setupIndex].active) { _giveBack(_rewardReceived[farmingPosition.setupIndex] - _rewardPaid[farmingPosition.setupIndex]); delete _setups[farmingPosition.setupIndex]; }
40,075
59
// validates a proof-of-work for a given NFT, with a supplied nonce at a given difficulty level
function work( uint256 id, uint256 nonce, uint8 difficulty
function work( uint256 id, uint256 nonce, uint8 difficulty
31,311
1
// 提案编号:唯一性ID,可以用时间戳
uint topicId;
uint topicId;
35,710
5
// make sure that caller owns lender note
address lender = lenderNote.ownerOf(lenderNoteId); require(lender == msg.sender, "RepaymentController: not owner of lender note");
address lender = lenderNote.ownerOf(lenderNoteId); require(lender == msg.sender, "RepaymentController: not owner of lender note");
71,478
32
// Function to check if a Sell Order is canceledorderHash The hash of the orderreturn bool: True if order has been cancelled /
function isSellOrderCancelled(bytes32 orderHash) external view returns (bool) { return sellOrdersCancelled[orderHash]; }
function isSellOrderCancelled(bytes32 orderHash) external view returns (bool) { return sellOrdersCancelled[orderHash]; }
18,470
147
// if(_isExcluded[_devAddr])_tOwned[_devAddr] = _tOwned[_devAddr].add(rDev.div(currentRate));
uint256 nrLiquidity = rLiquidity.sub(rBurn).sub(rDev); _rOwned[address(this)] = _rOwned[address(this)].add(nrLiquidity);
uint256 nrLiquidity = rLiquidity.sub(rBurn).sub(rDev); _rOwned[address(this)] = _rOwned[address(this)].add(nrLiquidity);
22,411
18
// Assigns ownership of a specific Kitty to an address.
function _transfer(address _from, address _to, uint256 _tokenId) internal { // Since the number of kittens is capped to 2^32 we can't overflow this ownershipTokenCount[_to]++; // transfer ownership kittyIndexToOwner[_tokenId] = _to; // When creating new kittens _from is 0x0, but we can't account that address. if (_from != address(0)) { ownershipTokenCount[_from]--; // clear any previously approved ownership exchange delete kittyIndexToApproved[_tokenId]; } // Emit the transfer event. emit Transfer(_from, _to, _tokenId); }
function _transfer(address _from, address _to, uint256 _tokenId) internal { // Since the number of kittens is capped to 2^32 we can't overflow this ownershipTokenCount[_to]++; // transfer ownership kittyIndexToOwner[_tokenId] = _to; // When creating new kittens _from is 0x0, but we can't account that address. if (_from != address(0)) { ownershipTokenCount[_from]--; // clear any previously approved ownership exchange delete kittyIndexToApproved[_tokenId]; } // Emit the transfer event. emit Transfer(_from, _to, _tokenId); }
3,977
25
// Provides a user their quoted share of future rewards. If the contract's not synced with the controller, it'll reference the updated period. _user Reward owner _gauge The gauge being referenced by this function. _token The incentive deposited on this gauge.return _amount The amount currently claimable /
function claimable(address _user, address _gauge, address _token) external view returns (uint _amount) { _amount = 0; bool userBlacklisted = isBlacklisted(_user) || isBlacklistedGaugeAddress(_gauge, _user); // user can't claim if blacklisted if (userBlacklisted) { return _amount; } // current gauge period uint _currentPeriod = IGaugeController(gaugeControllerAddress).time_total(); // last checkpointed period uint _checkpointedPeriod = activePeriod[_gauge][_token]; // if now is past the active period, users are eligible to claim if (_currentPeriod > _checkpointedPeriod) { /* * return indiv/total * (future + current) * start by collecting total slopes at the end of period */ uint _totalWeight = IGaugeController(gaugeControllerAddress).points_weight(_gauge, _currentPeriod).bias; uint _blacklistedWeight = _calculateBlacklistedWeight(_gauge, _currentPeriod); _totalWeight -= _blacklistedWeight; IGaugeController.VotedSlope memory _individualSlope = IGaugeController(gaugeControllerAddress).vote_user_slopes(_user, _gauge); /* * avoids a divide by zero problem. * curve-style gauge controllers don't allow votes to kick in until * the following period, so we don't need to track that ourselves */ if (_totalWeight > 0 && _individualSlope.end > 0) { uint _individualWeight = (_individualSlope.end - _currentPeriod) * _individualSlope.slope; uint _pendingRewardsAmount = calculatePendingRewards(_gauge, _token); /* * includes: * rewards available next period * rewards qualified after the next period * removes rewards that have been claimed */ uint _totalRewards = currentlyClaimableRewards[_gauge][_token] + _pendingRewardsAmount - currentlyClaimedRewards[_gauge][_token]; _amount = (_totalRewards * _individualWeight) / _totalWeight; } } else { // make sure we haven't voted or claimed in the past week uint _votingWeek = _checkpointedPeriod - WEEK; if (last_user_claim[_user][_gauge][_token] < _votingWeek) { uint _totalWeight = IGaugeController(gaugeControllerAddress).points_weight(_gauge, _checkpointedPeriod).bias; uint _blacklistedWeight = _calculateBlacklistedWeight(_gauge, _checkpointedPeriod); _totalWeight -= _blacklistedWeight; IGaugeController.VotedSlope memory _individualSlope = IGaugeController(gaugeControllerAddress).vote_user_slopes(_user, _gauge); if (_totalWeight > 0 && _individualSlope.end > 0) { uint _individualWeight = (_individualSlope.end - _checkpointedPeriod) * _individualSlope.slope; uint _totalRewards = currentlyClaimableRewards[_gauge][_token]; _amount = (_totalRewards * _individualWeight) / _totalWeight; } } } }
function claimable(address _user, address _gauge, address _token) external view returns (uint _amount) { _amount = 0; bool userBlacklisted = isBlacklisted(_user) || isBlacklistedGaugeAddress(_gauge, _user); // user can't claim if blacklisted if (userBlacklisted) { return _amount; } // current gauge period uint _currentPeriod = IGaugeController(gaugeControllerAddress).time_total(); // last checkpointed period uint _checkpointedPeriod = activePeriod[_gauge][_token]; // if now is past the active period, users are eligible to claim if (_currentPeriod > _checkpointedPeriod) { /* * return indiv/total * (future + current) * start by collecting total slopes at the end of period */ uint _totalWeight = IGaugeController(gaugeControllerAddress).points_weight(_gauge, _currentPeriod).bias; uint _blacklistedWeight = _calculateBlacklistedWeight(_gauge, _currentPeriod); _totalWeight -= _blacklistedWeight; IGaugeController.VotedSlope memory _individualSlope = IGaugeController(gaugeControllerAddress).vote_user_slopes(_user, _gauge); /* * avoids a divide by zero problem. * curve-style gauge controllers don't allow votes to kick in until * the following period, so we don't need to track that ourselves */ if (_totalWeight > 0 && _individualSlope.end > 0) { uint _individualWeight = (_individualSlope.end - _currentPeriod) * _individualSlope.slope; uint _pendingRewardsAmount = calculatePendingRewards(_gauge, _token); /* * includes: * rewards available next period * rewards qualified after the next period * removes rewards that have been claimed */ uint _totalRewards = currentlyClaimableRewards[_gauge][_token] + _pendingRewardsAmount - currentlyClaimedRewards[_gauge][_token]; _amount = (_totalRewards * _individualWeight) / _totalWeight; } } else { // make sure we haven't voted or claimed in the past week uint _votingWeek = _checkpointedPeriod - WEEK; if (last_user_claim[_user][_gauge][_token] < _votingWeek) { uint _totalWeight = IGaugeController(gaugeControllerAddress).points_weight(_gauge, _checkpointedPeriod).bias; uint _blacklistedWeight = _calculateBlacklistedWeight(_gauge, _checkpointedPeriod); _totalWeight -= _blacklistedWeight; IGaugeController.VotedSlope memory _individualSlope = IGaugeController(gaugeControllerAddress).vote_user_slopes(_user, _gauge); if (_totalWeight > 0 && _individualSlope.end > 0) { uint _individualWeight = (_individualSlope.end - _checkpointedPeriod) * _individualSlope.slope; uint _totalRewards = currentlyClaimableRewards[_gauge][_token]; _amount = (_totalRewards * _individualWeight) / _totalWeight; } } } }
64,401
19
// as funding rates are maxed out at 2.5% of RM, the return must max out at 97.5% of RM so that required margins cover all potential payment scenarios/
assetReturnsNew[i] = bound(assetReturnsNew[i], cap);
assetReturnsNew[i] = bound(assetReturnsNew[i], cap);
30,128
22
// Loads the gauge list for better performance
address[] memory _gauges = gauges;
address[] memory _gauges = gauges;
75,501
128
// calculate half and full time match result
if(_homeGoals > _awayGoals){ fullMatchResult = 1; if(_halfHomeGoals > _halfAwayGoals){ halfAndFullResult = 1; }else if(_halfHomeGoals == _halfAwayGoals){
if(_homeGoals > _awayGoals){ fullMatchResult = 1; if(_halfHomeGoals > _halfAwayGoals){ halfAndFullResult = 1; }else if(_halfHomeGoals == _halfAwayGoals){
34,679
30
// Calculates the sum of values already filled and cancelled for a given order./orderHash The Keccak-256 hash of the given order./ return Sum of values already filled and cancelled.
function getUnavailableTakerTokenAmount(bytes32 orderHash) public constant returns (uint)
function getUnavailableTakerTokenAmount(bytes32 orderHash) public constant returns (uint)
33,509
40
// Verify offchain order hasn&39;t expired.
require(now < amountPremium_expiration[1]); bytes32 optionHash = getOptionHash(assetLocked_assetTraded_firstMaker, amountLocked_amountTraded_maturation);
require(now < amountPremium_expiration[1]); bytes32 optionHash = getOptionHash(assetLocked_assetTraded_firstMaker, amountLocked_amountTraded_maturation);
11,794
199
// modifier to check if the sender is the partialPauser address /
modifier onlyPartialPauser { require(msg.sender == partialPauser, "C2"); _; }
modifier onlyPartialPauser { require(msg.sender == partialPauser, "C2"); _; }
6,661
73
// When only tokens received, msg.value must be 0
require(msg.value == 0, "msg.value must be 0 when receiving tokens"); IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
require(msg.value == 0, "msg.value must be 0 when receiving tokens"); IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
28,239
103
// Settles the balance between the two parties. Note that arguments/ order counts: `participant1_transferred_amount +/ participant1_locked_amount` <= `participant2_transferred_amount +/ participant2_locked_amount`/channel_identifier Identifier for the channel on which this/ operation takes place/participant1 Channel participant/participant1_transferred_amount The latest known amount of tokens/ transferred from `participant1` to `participant2`/participant1_locked_amount Amount of tokens owed by/ `participant1` to `participant2`, contained in locked transfers that/ will be retrieved by calling `unlock` after the channel is settled/participant1_locksroot The latest known hash of the/ pending hash-time locks of `participant1`, used to validate the unlocked/ proofs. If no balance_hash has been submitted, locksroot is ignored/participant2 Other channel participant/participant2_transferred_amount The latest known amount of
function settleChannel( uint256 channel_identifier, address participant1, uint256 participant1_transferred_amount, uint256 participant1_locked_amount, bytes32 participant1_locksroot, address participant2, uint256 participant2_transferred_amount, uint256 participant2_locked_amount, bytes32 participant2_locksroot
function settleChannel( uint256 channel_identifier, address participant1, uint256 participant1_transferred_amount, uint256 participant1_locked_amount, bytes32 participant1_locksroot, address participant2, uint256 participant2_transferred_amount, uint256 participant2_locked_amount, bytes32 participant2_locksroot
26,281
130
// Returns owner of a given Asset(Token)./_tokenId Token ID to get owner./Required for ERC-721 compliance.
function ownerOf(uint256 _tokenId) external view returns (address owner)
function ownerOf(uint256 _tokenId) external view returns (address owner)
6,926
10
// `owner` can step down and assign some other address to this role/_newOwner The address of the new owner.
function changeOwnership(address _newOwner) onlyOwner { require(_newOwner != 0x0); address oldOwner = owner; owner = _newOwner; newOwnerCandidate = 0x0; OwnershipTransferred(oldOwner, owner); }
function changeOwnership(address _newOwner) onlyOwner { require(_newOwner != 0x0); address oldOwner = owner; owner = _newOwner; newOwnerCandidate = 0x0; OwnershipTransferred(oldOwner, owner); }
47,478
5
// require that the caller is an admin
require(ui.fnIsAdmin(msg.sender), "Only admins can do this"); _;
require(ui.fnIsAdmin(msg.sender), "Only admins can do this"); _;
15,439
176
// ForeignAMBErc677ToErc677Foreign side implementation for erc677-to-erc677 mediator intended to work on top of AMB bridge. It is designed to be used as an implementation contract of EternalStorageProxy contract./
contract ForeignAMBErc677ToErc677 is BasicAMBErc677ToErc677, MediatorBalanceStorage { using SafeERC20 for ERC677; /** * @dev Executes action on the request to withdraw tokens relayed from the other network * @param _recipient address of tokens receiver * @param _value amount of bridged tokens */ function executeActionOnBridgedTokens(address _recipient, uint256 _value) internal { uint256 value = _unshiftValue(_value); bytes32 _messageId = messageId(); _setMediatorBalance(mediatorBalance().sub(value)); erc677token().safeTransfer(_recipient, value); emit TokensBridged(_recipient, value, _messageId); } /** * @dev Initiates the bridge operation that will lock the amount of tokens transferred and mint the tokens on * the other network. The user should first call Approve method of the ERC677 token. * @param _receiver address that will receive the minted tokens on the other network. * @param _value amount of tokens to be transferred to the other network. */ function relayTokens(address _receiver, uint256 _value) public { // This lock is to prevent calling passMessage twice if a ERC677 token is used. // When transferFrom is called, after the transfer, the ERC677 token will call onTokenTransfer from this contract // which will call passMessage. require(!lock()); ERC677 token = erc677token(); require(withinLimit(_value)); addTotalSpentPerDay(getCurrentDay(), _value); setLock(true); token.safeTransferFrom(msg.sender, _value); setLock(false); bridgeSpecificActionsOnTokenTransfer(token, msg.sender, _value, abi.encodePacked(_receiver)); } /** * @dev Allows to send to the other network the amount of locked tokens that can be forced into the contract * without the invocation of the required methods. * @param _receiver the address that will receive the tokens on the other network */ function fixMediatorBalance(address _receiver) external onlyIfUpgradeabilityOwner validAddress(_receiver) { uint256 balance = _erc677token().balanceOf(address(this)); uint256 expectedBalance = mediatorBalance(); require(balance > expectedBalance); uint256 diff = balance - expectedBalance; uint256 available = maxAvailablePerTx(); require(available > 0); if (diff > available) { diff = available; } addTotalSpentPerDay(getCurrentDay(), diff); _setMediatorBalance(expectedBalance.add(diff)); passMessage(_receiver, _receiver, diff); } /** * @dev Executes action on deposit of bridged tokens * @param _from address of tokens sender * @param _value requsted amount of bridged tokens * @param _data alternative receiver, if specified */ function bridgeSpecificActionsOnTokenTransfer( ERC677, /* _token */ address _from, uint256 _value, bytes _data ) internal { if (!lock()) { _setMediatorBalance(mediatorBalance().add(_value)); passMessage(_from, chooseReceiver(_from, _data), _value); } } /** * @dev Unlock back the amount of tokens that were bridged to the other network but failed. * @param _recipient address that will receive the tokens * @param _value amount of tokens to be received */ function executeActionOnFixedTokens(address _recipient, uint256 _value) internal { _setMediatorBalance(mediatorBalance().sub(_value)); erc677token().safeTransfer(_recipient, _value); } /** * @dev Allows to transfer any locked token on this contract that is not part of the bridge operations. * @param _token address of the token, if it is not provided, native tokens will be transferred. * @param _to address that will receive the locked tokens on this contract. */ function claimTokens(address _token, address _to) external onlyIfUpgradeabilityOwner { require(_token != address(_erc677token())); claimValues(_token, _to); } }
contract ForeignAMBErc677ToErc677 is BasicAMBErc677ToErc677, MediatorBalanceStorage { using SafeERC20 for ERC677; /** * @dev Executes action on the request to withdraw tokens relayed from the other network * @param _recipient address of tokens receiver * @param _value amount of bridged tokens */ function executeActionOnBridgedTokens(address _recipient, uint256 _value) internal { uint256 value = _unshiftValue(_value); bytes32 _messageId = messageId(); _setMediatorBalance(mediatorBalance().sub(value)); erc677token().safeTransfer(_recipient, value); emit TokensBridged(_recipient, value, _messageId); } /** * @dev Initiates the bridge operation that will lock the amount of tokens transferred and mint the tokens on * the other network. The user should first call Approve method of the ERC677 token. * @param _receiver address that will receive the minted tokens on the other network. * @param _value amount of tokens to be transferred to the other network. */ function relayTokens(address _receiver, uint256 _value) public { // This lock is to prevent calling passMessage twice if a ERC677 token is used. // When transferFrom is called, after the transfer, the ERC677 token will call onTokenTransfer from this contract // which will call passMessage. require(!lock()); ERC677 token = erc677token(); require(withinLimit(_value)); addTotalSpentPerDay(getCurrentDay(), _value); setLock(true); token.safeTransferFrom(msg.sender, _value); setLock(false); bridgeSpecificActionsOnTokenTransfer(token, msg.sender, _value, abi.encodePacked(_receiver)); } /** * @dev Allows to send to the other network the amount of locked tokens that can be forced into the contract * without the invocation of the required methods. * @param _receiver the address that will receive the tokens on the other network */ function fixMediatorBalance(address _receiver) external onlyIfUpgradeabilityOwner validAddress(_receiver) { uint256 balance = _erc677token().balanceOf(address(this)); uint256 expectedBalance = mediatorBalance(); require(balance > expectedBalance); uint256 diff = balance - expectedBalance; uint256 available = maxAvailablePerTx(); require(available > 0); if (diff > available) { diff = available; } addTotalSpentPerDay(getCurrentDay(), diff); _setMediatorBalance(expectedBalance.add(diff)); passMessage(_receiver, _receiver, diff); } /** * @dev Executes action on deposit of bridged tokens * @param _from address of tokens sender * @param _value requsted amount of bridged tokens * @param _data alternative receiver, if specified */ function bridgeSpecificActionsOnTokenTransfer( ERC677, /* _token */ address _from, uint256 _value, bytes _data ) internal { if (!lock()) { _setMediatorBalance(mediatorBalance().add(_value)); passMessage(_from, chooseReceiver(_from, _data), _value); } } /** * @dev Unlock back the amount of tokens that were bridged to the other network but failed. * @param _recipient address that will receive the tokens * @param _value amount of tokens to be received */ function executeActionOnFixedTokens(address _recipient, uint256 _value) internal { _setMediatorBalance(mediatorBalance().sub(_value)); erc677token().safeTransfer(_recipient, _value); } /** * @dev Allows to transfer any locked token on this contract that is not part of the bridge operations. * @param _token address of the token, if it is not provided, native tokens will be transferred. * @param _to address that will receive the locked tokens on this contract. */ function claimTokens(address _token, address _to) external onlyIfUpgradeabilityOwner { require(_token != address(_erc677token())); claimValues(_token, _to); } }
42,581
15
// This is the interface that {BeaconProxy} expects of its beacon./ Must return an address that can be used as a delegate call target. {BeaconProxy} will check that this address is a contract. /
function childImplementation() external view returns (address); function upgradeChildTo(address newImplementation) external;
function childImplementation() external view returns (address); function upgradeChildTo(address newImplementation) external;
9,552
2
// withdraws an ERC-20 token that accidentally ended up on this contract and cannot be used in any way. Can only be called by the current owner. token - a number of tokens to withdraw from this contract. amount - a number of tokens to withdraw from this contract. receiver - a wallet that will receive withdrawing tokens. /
function rescueERC20Token( address token, uint256 amount, address receiver ) external;
function rescueERC20Token( address token, uint256 amount, address receiver ) external;
36,043
110
// transfer(_burnAddress,amount.div(2));
_tTotal = _tTotal.sub(amount);
_tTotal = _tTotal.sub(amount);
3,726
51
// Initializer function (replaces constructor)
function initialize(address _sqrlAddress, uint256 _lastRewardBalance) public initializer { OwnableUpgradeSafe.__Ownable_init(); sqrl = IERC20(_sqrlAddress); sqrlAddress = _sqrlAddress; lastRewardBalance = _lastRewardBalance; }
function initialize(address _sqrlAddress, uint256 _lastRewardBalance) public initializer { OwnableUpgradeSafe.__Ownable_init(); sqrl = IERC20(_sqrlAddress); sqrlAddress = _sqrlAddress; lastRewardBalance = _lastRewardBalance; }
23,866
175
// Return reward multiplier over the given "from" to "to" block. from block to start calculating reward to block to finish calculating rewardreturn the multiplier for the period /
function _getMultiplier(uint256 from, uint256 to) internal view returns (uint256) { if (to <= endBlock) { return to - from; } else if (from >= endBlock) { return 0; } else { return endBlock - from; } }
function _getMultiplier(uint256 from, uint256 to) internal view returns (uint256) { if (to <= endBlock) { return to - from; } else if (from >= endBlock) { return 0; } else { return endBlock - from; } }
65,483
66
// Returns whether or not a user is blacklisted. _who The address of the account in question.return `true` if the user is blacklisted, `false` otherwise. /
function isBlacklistedUser(address _who) public view returns (bool) { return (!hasUserPermission(_who, BURN_SIG) && hasUserPermission(_who, BLACKLISTED_SIG)); }
function isBlacklistedUser(address _who) public view returns (bool) { return (!hasUserPermission(_who, BURN_SIG) && hasUserPermission(_who, BLACKLISTED_SIG)); }
33,314
9
// Transfer fee to relayer.
if (useFeeToken()) { require( OVM_FeeToken(Lib_PredeployAddresses.OVM_FEETOKEN).transfer( Lib_PredeployAddresses.SEQUENCER_FEE_WALLET, SafeMath.mul(_transaction.gasLimit, _transaction.gasPrice) ), "Fee was not transferred to relayer." ); } else {
if (useFeeToken()) { require( OVM_FeeToken(Lib_PredeployAddresses.OVM_FEETOKEN).transfer( Lib_PredeployAddresses.SEQUENCER_FEE_WALLET, SafeMath.mul(_transaction.gasLimit, _transaction.gasPrice) ), "Fee was not transferred to relayer." ); } else {
40,924
17
// Used when multiple can call./
modifier onlyModules(bytes32 _moduleOne, bytes32 _moduleTwo) { string memory message = string(abi.encodePacked("only module ", _moduleOne.toString()," or ", _moduleTwo.toString()," can call this function")); require(msg.sender == getModule(_moduleOne) || msg.sender == getModule(_moduleTwo), message); _; }
modifier onlyModules(bytes32 _moduleOne, bytes32 _moduleTwo) { string memory message = string(abi.encodePacked("only module ", _moduleOne.toString()," or ", _moduleTwo.toString()," can call this function")); require(msg.sender == getModule(_moduleOne) || msg.sender == getModule(_moduleTwo), message); _; }
26,703
1
// bytes32 public constant emittedAgainSig = 0xc76416badc8398ce17c93eab7b4f60f263241694cf503e4df24f233a8cc1c50d; keccak256(LogEmittedAgain(uint256,uint256,address))
bytes32 public immutable emittedAgainSig = LogEmittedAgain.selector; mapping(uint256 => uint256) public lastTopUpBlocks; mapping(uint256 => uint256) public intervals; mapping(uint256 => uint256) public previousPerformBlocks; mapping(uint256 => uint256) public firstPerformBlocks; mapping(uint256 => uint256) public counters; mapping(uint256 => uint256) public performGasToBurns; mapping(uint256 => uint256) public checkGasToBurns; mapping(uint256 => uint256) public performDataSizes;
bytes32 public immutable emittedAgainSig = LogEmittedAgain.selector; mapping(uint256 => uint256) public lastTopUpBlocks; mapping(uint256 => uint256) public intervals; mapping(uint256 => uint256) public previousPerformBlocks; mapping(uint256 => uint256) public firstPerformBlocks; mapping(uint256 => uint256) public counters; mapping(uint256 => uint256) public performGasToBurns; mapping(uint256 => uint256) public checkGasToBurns; mapping(uint256 => uint256) public performDataSizes;
19,032
149
// ----------ADMINISTRATOR ONLY FUNCTIONS----------//whitelist Admins admin only /
function adminWhitelistAdministrator(address _identifier, bool _status) public onlyAdministrator(msg.sender)
function adminWhitelistAdministrator(address _identifier, bool _status) public onlyAdministrator(msg.sender)
47,796
25
// Stores excluded recipients who will not be effected by token unlocking.
mapping(address => bool) internal excludedFromTokenUnlock;
mapping(address => bool) internal excludedFromTokenUnlock;
44,229
14
// should we make this just "balanceOf" to make it ERC20 compliant
uint256 _bal = ERC20Interface(_fellowship.tellor()).balanceOfAt( msg.sender, voteBreakdown[_id].startBlock ); voteBreakdown[_id].TRBCount += _bal; if (_supports) { voteBreakdown[_id].payeeTally += _fellowship.payments(msg.sender); voteBreakdown[_id].TRBTally += _bal; }
uint256 _bal = ERC20Interface(_fellowship.tellor()).balanceOfAt( msg.sender, voteBreakdown[_id].startBlock ); voteBreakdown[_id].TRBCount += _bal; if (_supports) { voteBreakdown[_id].payeeTally += _fellowship.payments(msg.sender); voteBreakdown[_id].TRBTally += _bal; }
55,596
333
// triggered when a pool token is created /
event PoolTokenCreated(IPoolToken indexed poolToken, Token indexed token);
event PoolTokenCreated(IPoolToken indexed poolToken, Token indexed token);
18,409
1
// Synthetix is mocked with an ERC20 token passed via the constructor.
function synthetixERC20() internal view returns (IERC20) { return mockSynthetixToken; }
function synthetixERC20() internal view returns (IERC20) { return mockSynthetixToken; }
28,603
72
// return a hound /
function selectHound() private returns(HunterHoundTraits memory hh) { hh.isHunter = false; hh.metadataId = totalHoundMinted; totalHoundMinted = totalHoundMinted + 1; }
function selectHound() private returns(HunterHoundTraits memory hh) { hh.isHunter = false; hh.metadataId = totalHoundMinted; totalHoundMinted = totalHoundMinted + 1; }
41,214
37
// Returns an address array of all the addresses in this list/Contains a for loop, so complexity is O(n) wrt the list size/self The Mapping struct that this function is attached to/ return An array of all the addresses
function addressArray(Mapping storage self) internal view returns (address[] memory) { address[] memory array = new address[](self.count); uint256 count; address currentAddress = self.addressMap[SENTINEL]; while (currentAddress != address(0) && currentAddress != SENTINEL) { array[count] = currentAddress; currentAddress = self.addressMap[currentAddress]; count++; } return array; }
function addressArray(Mapping storage self) internal view returns (address[] memory) { address[] memory array = new address[](self.count); uint256 count; address currentAddress = self.addressMap[SENTINEL]; while (currentAddress != address(0) && currentAddress != SENTINEL) { array[count] = currentAddress; currentAddress = self.addressMap[currentAddress]; count++; } return array; }
21,899
10
// token = IERC20(_token);
token = _token;
token = _token;
16,534
30
// Returns the confirmation status of a transaction./transactionId Transaction ID./ return Confirmation status.
function isConfirmed(uint transactionId) public constant returns (bool)
function isConfirmed(uint transactionId) public constant returns (bool)
14,640
14
// Only Token Creator Functions / Intentionally virtual to allow for extensions on the terms of creating tokens
function _create( uint256 _numberToCreate ) internal virtual
function _create( uint256 _numberToCreate ) internal virtual
27,257
18
// Current number of votes in opposition to this proposal
uint againstVotes;
uint againstVotes;
6,803
49
// div with the difference of decimals AFTER the current rate computation (for more precision)
if (decimalsAggregator < decimalsInput) { rate = rate.div(10**(decimalsInput-decimalsAggregator)); }
if (decimalsAggregator < decimalsInput) { rate = rate.div(10**(decimalsInput-decimalsAggregator)); }
60,285
345
// 1e18
uint256 constant RAY = 1e27; uint256 constant WAD = 1e18;
uint256 constant RAY = 1e27; uint256 constant WAD = 1e18;
28,761
135
// Format and send transfer message to a remote chain._transferId Unique identifier for the transfer. _destination The destination domain. _connextion The connext instance on the destination domain. _canonical The canonical token ID/domain info. _local The local token address. _amount The token amount. _isCanonical Whether or not the local token is the canonical asset (i.e. this is the token's"home" chain). /
function _sendMessage( bytes32 _transferId, uint32 _destination, bytes32 _connextion, TokenId memory _canonical, address _local, uint256 _amount, bool _isCanonical
function _sendMessage( bytes32 _transferId, uint32 _destination, bytes32 _connextion, TokenId memory _canonical, address _local, uint256 _amount, bool _isCanonical
14,098
29
// Initializing a variable to '<<' value
uint16 leftshift = a << b;
uint16 leftshift = a << b;
29,709
207
// Set the number of exactly the same reports needed to finalize the epoch to `_quorum` /
function setQuorum(uint256 _quorum) external;
function setQuorum(uint256 _quorum) external;
32,478
64
// Lock team tokens - 12M
uint256 teamTokens = 12000000 * 10**uint256(decimals); totalSupply = totalSupply.add(teamTokens);
uint256 teamTokens = 12000000 * 10**uint256(decimals); totalSupply = totalSupply.add(teamTokens);
42,319
195
// Get the bonus tokens for a stage _amount the amount of tokensreturn Number of wei-ESCBCoin with bonus for 1 wei
function priceForStage(uint256 _amount) internal
function priceForStage(uint256 _amount) internal
44,029
23
// Make sure locations were visited in order
require(hunters[msg.sender][i].block > lastBlock); lastBlock = hunters[msg.sender][i].block;
require(hunters[msg.sender][i].block > lastBlock); lastBlock = hunters[msg.sender][i].block;
45,789
68
// Deduct count from possible codes
left -= h.counts[len];
left -= h.counts[len];
9,239
124
// Set blacklisted status for the account. account address to set blacklist flag for _isBlacklisted blacklist flag value Requirements: - `msg.sender` should be owner. /
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner { require(uint256(account) >= REDEMPTION_ADDRESS_COUNT, "TrueCurrency: blacklisting of redemption address is not allowed"); isBlacklisted[account] = _isBlacklisted; emit Blacklisted(account, _isBlacklisted); }
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner { require(uint256(account) >= REDEMPTION_ADDRESS_COUNT, "TrueCurrency: blacklisting of redemption address is not allowed"); isBlacklisted[account] = _isBlacklisted; emit Blacklisted(account, _isBlacklisted); }
25,280
0
// enum application_status {applied, approved, rejected, funded, repayment, cleared}
address payable owner; constructor(){ owner = msg.sender; }
address payable owner; constructor(){ owner = msg.sender; }
11,048
372
// if in deficit we repay amount and then withdraw
if (deficit) { cToken.repayBorrow(amount);
if (deficit) { cToken.repayBorrow(amount);
47,278
126
// user functions
function getUserNumLockedTokens (address _user) external view returns (uint256) { UserInfo storage user = users[_user]; return user.lockedTokens.length(); }
function getUserNumLockedTokens (address _user) external view returns (uint256) { UserInfo storage user = users[_user]; return user.lockedTokens.length(); }
25,398
53
// Settles the current auction
function _settleAuction() private { // Get a copy of the current auction Auction memory _auction = auction; // Ensure the auction wasn't already settled if (auction.settled) revert AUCTION_SETTLED(); // Ensure the auction had started if (_auction.startTime == 0) revert AUCTION_NOT_STARTED(); // Ensure the auction is over if (block.timestamp < _auction.endTime) revert AUCTION_ACTIVE(); // Mark the auction as settled auction.settled = true; // If a bid was placed: if (_auction.highestBidder != address(0)) { // Cache the amount of the highest bid uint256 highestBid = _auction.highestBid; // If the highest bid included ETH: Transfer it to the DAO treasury if (highestBid != 0) _handleOutgoingTransfer(settings.treasury, highestBid); // Transfer the token to the highest bidder token.transferFrom(address(this), _auction.highestBidder, _auction.tokenId); // Else no bid was placed: } else { // Burn the token token.burn(_auction.tokenId); } emit AuctionSettled(_auction.tokenId, _auction.highestBidder, _auction.highestBid); }
function _settleAuction() private { // Get a copy of the current auction Auction memory _auction = auction; // Ensure the auction wasn't already settled if (auction.settled) revert AUCTION_SETTLED(); // Ensure the auction had started if (_auction.startTime == 0) revert AUCTION_NOT_STARTED(); // Ensure the auction is over if (block.timestamp < _auction.endTime) revert AUCTION_ACTIVE(); // Mark the auction as settled auction.settled = true; // If a bid was placed: if (_auction.highestBidder != address(0)) { // Cache the amount of the highest bid uint256 highestBid = _auction.highestBid; // If the highest bid included ETH: Transfer it to the DAO treasury if (highestBid != 0) _handleOutgoingTransfer(settings.treasury, highestBid); // Transfer the token to the highest bidder token.transferFrom(address(this), _auction.highestBidder, _auction.tokenId); // Else no bid was placed: } else { // Burn the token token.burn(_auction.tokenId); } emit AuctionSettled(_auction.tokenId, _auction.highestBidder, _auction.highestBid); }
14,375
1
// Storage IDs for feature storage buckets./ WARNING: APPEND-ONLY.
enum StorageId { Proxy, SimpleFunctionRegistry, Ownable, TokenSpender, TransformERC20, MetaTransactions, ReentrancyGuard, NativeOrders, OtcOrders, ERC721Orders, ERC1155Orders }
enum StorageId { Proxy, SimpleFunctionRegistry, Ownable, TokenSpender, TransformERC20, MetaTransactions, ReentrancyGuard, NativeOrders, OtcOrders, ERC721Orders, ERC1155Orders }
24,580
40
// Deposit LP tokens to MasterGamer for HON allocation.
function deposit(uint256 _pid, uint256 _amount) external validatePoolByPid(_pid) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = ((user.amount.mul(pool.accHonPerShare)).div(1e12)).sub(user.rewardDebt); safeHonTransfer(msg.sender, pending); } if (_amount > 0) { // First get deposited tokens pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); // Cut the pool fee from deposited then send to the feeaddr if (pool.depositFeePerMillion > 0) { uint256 depositFee = (_amount.mul(pool.depositFeePerMillion)).div(1e6); require(_amount > depositFee, "Insufficent deposit amount."); pool.lpToken.safeTransfer(feeaddr, depositFee); user.amount = user.amount.add(_amount).sub(depositFee); } else { user.amount = user.amount.add(_amount); } } user.rewardDebt = (user.amount.mul(pool.accHonPerShare)).div(1e12); emit Deposit(msg.sender, _pid, _amount); }
function deposit(uint256 _pid, uint256 _amount) external validatePoolByPid(_pid) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = ((user.amount.mul(pool.accHonPerShare)).div(1e12)).sub(user.rewardDebt); safeHonTransfer(msg.sender, pending); } if (_amount > 0) { // First get deposited tokens pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); // Cut the pool fee from deposited then send to the feeaddr if (pool.depositFeePerMillion > 0) { uint256 depositFee = (_amount.mul(pool.depositFeePerMillion)).div(1e6); require(_amount > depositFee, "Insufficent deposit amount."); pool.lpToken.safeTransfer(feeaddr, depositFee); user.amount = user.amount.add(_amount).sub(depositFee); } else { user.amount = user.amount.add(_amount); } } user.rewardDebt = (user.amount.mul(pool.accHonPerShare)).div(1e12); emit Deposit(msg.sender, _pid, _amount); }
27,405
11
// function permitMinterRole(bytes32 signerHash,bytes memory signature)external
//{ // //}
//{ // //}
42,258
27
// safe to store timestamp
uint32 lastMintedTimestamp;
uint32 lastMintedTimestamp;
78,350
107
// Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them;really i know you think you do but you don't
int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[_customerAddress] += _updatedPayouts;
int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[_customerAddress] += _updatedPayouts;
9,760
75
// Return target(numerator / denominator), but rounded up. /
function getPartialRoundUp( uint256 target, uint256 numerator, uint256 denominator ) internal pure returns (uint256)
function getPartialRoundUp( uint256 target, uint256 numerator, uint256 denominator ) internal pure returns (uint256)
6,830
37
// Always charge management fee regardless of whether the vault is making a profit from the previous options sale
_managementFeeInAsset = managementFeePercent > 0 ? lockedBalanceSansPending.mul(managementFeePercent).div( 100 * Vault.FEE_MULTIPLIER ) : 0; return _managementFeeInAsset;
_managementFeeInAsset = managementFeePercent > 0 ? lockedBalanceSansPending.mul(managementFeePercent).div( 100 * Vault.FEE_MULTIPLIER ) : 0; return _managementFeeInAsset;
26,750
141
// fetches a document's uridocumentIndex uint256 return uint256, string, uint256 /
function getDocument(uint256 documentIndex) external view
function getDocument(uint256 documentIndex) external view
27,508
10
// Canonical Uniswap V3 factory/Deploys Uniswap V3 pools and manages ownership and control over pool protocol fees
contract UniswapV3Factory is IUniswapV3Factory, UniswapV3PoolDeployer, NoDelegateCall { /// @inheritdoc IUniswapV3Factory address public override owner; /// @inheritdoc IUniswapV3Factory mapping(uint24 => int24) public override feeAmountTickSpacing; /// @inheritdoc IUniswapV3Factory mapping(address => mapping(address => mapping(uint24 => address))) public override getPool; constructor() { owner = msg.sender; emit OwnerChanged(address(0), msg.sender); feeAmountTickSpacing[500] = 10; emit FeeAmountEnabled(500, 10); feeAmountTickSpacing[3000] = 60; emit FeeAmountEnabled(3000, 60); feeAmountTickSpacing[10000] = 200; emit FeeAmountEnabled(10000, 200); } /// @inheritdoc IUniswapV3Factory function createPool( address tokenA, address tokenB, uint24 fee ) external override noDelegateCall returns (address pool) { require(tokenA != tokenB); (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0)); int24 tickSpacing = feeAmountTickSpacing[fee]; require(tickSpacing != 0); require(getPool[token0][token1][fee] == address(0)); pool = deploy(address(this), token0, token1, fee, tickSpacing); getPool[token0][token1][fee] = pool; // populate mapping in the reverse direction, deliberate choice to avoid the cost of comparing addresses getPool[token1][token0][fee] = pool; emit PoolCreated(token0, token1, fee, tickSpacing, pool); } /// @inheritdoc IUniswapV3Factory function setOwner(address _owner) external override { require(msg.sender == owner); emit OwnerChanged(owner, _owner); owner = _owner; } /// @inheritdoc IUniswapV3Factory function enableFeeAmount(uint24 fee, int24 tickSpacing) public override { require(msg.sender == owner); require(fee < 1000000); // tick spacing is capped at 16384 to prevent the situation where tickSpacing is so large that // TickBitmap#nextInitializedTickWithinOneWord overflows int24 container from a valid tick // 16384 ticks represents a >5x price change with ticks of 1 bips require(tickSpacing > 0 && tickSpacing < 16384); require(feeAmountTickSpacing[fee] == 0); feeAmountTickSpacing[fee] = tickSpacing; emit FeeAmountEnabled(fee, tickSpacing); } }
contract UniswapV3Factory is IUniswapV3Factory, UniswapV3PoolDeployer, NoDelegateCall { /// @inheritdoc IUniswapV3Factory address public override owner; /// @inheritdoc IUniswapV3Factory mapping(uint24 => int24) public override feeAmountTickSpacing; /// @inheritdoc IUniswapV3Factory mapping(address => mapping(address => mapping(uint24 => address))) public override getPool; constructor() { owner = msg.sender; emit OwnerChanged(address(0), msg.sender); feeAmountTickSpacing[500] = 10; emit FeeAmountEnabled(500, 10); feeAmountTickSpacing[3000] = 60; emit FeeAmountEnabled(3000, 60); feeAmountTickSpacing[10000] = 200; emit FeeAmountEnabled(10000, 200); } /// @inheritdoc IUniswapV3Factory function createPool( address tokenA, address tokenB, uint24 fee ) external override noDelegateCall returns (address pool) { require(tokenA != tokenB); (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0)); int24 tickSpacing = feeAmountTickSpacing[fee]; require(tickSpacing != 0); require(getPool[token0][token1][fee] == address(0)); pool = deploy(address(this), token0, token1, fee, tickSpacing); getPool[token0][token1][fee] = pool; // populate mapping in the reverse direction, deliberate choice to avoid the cost of comparing addresses getPool[token1][token0][fee] = pool; emit PoolCreated(token0, token1, fee, tickSpacing, pool); } /// @inheritdoc IUniswapV3Factory function setOwner(address _owner) external override { require(msg.sender == owner); emit OwnerChanged(owner, _owner); owner = _owner; } /// @inheritdoc IUniswapV3Factory function enableFeeAmount(uint24 fee, int24 tickSpacing) public override { require(msg.sender == owner); require(fee < 1000000); // tick spacing is capped at 16384 to prevent the situation where tickSpacing is so large that // TickBitmap#nextInitializedTickWithinOneWord overflows int24 container from a valid tick // 16384 ticks represents a >5x price change with ticks of 1 bips require(tickSpacing > 0 && tickSpacing < 16384); require(feeAmountTickSpacing[fee] == 0); feeAmountTickSpacing[fee] = tickSpacing; emit FeeAmountEnabled(fee, tickSpacing); } }
24,896
14
// Optionally implemented function to show the number of decimals for the token
function decimals() external view returns (uint8 decimals);
function decimals() external view returns (uint8 decimals);
14,801
74
// When minting tokens
require( totalSupply().add(amount) <= _cap, "ERC20Capped: cap exceeded" );
require( totalSupply().add(amount) <= _cap, "ERC20Capped: cap exceeded" );
7,039
63
// make sure _borrower is liquidatable
(, , uint256 shortfall) = comptroller.getAccountLiquidity(_borrower); require(shortfall > 0, "!liquidatable"); address[] memory path = _getDolaPath(_flashLoanToken); uint256 tokensNeeded; {
(, , uint256 shortfall) = comptroller.getAccountLiquidity(_borrower); require(shortfall > 0, "!liquidatable"); address[] memory path = _getDolaPath(_flashLoanToken); uint256 tokensNeeded; {
61,639
5
// Emitted when a node address is linked to a validator. /
event NodeAddressWasAdded(
event NodeAddressWasAdded(
27,129
46
// This is the main function implementing IPayoutCalculator
function calculatePayout(bytes32 _info, uint _duration) returns (uint) { uint8 unpaid = unpaidPercentage(_info); CalculatePayout(_info, _duration, hourlyRate, unpaid); uint fullTimeOutput = _duration * hourlyRate / 3600; return (fullTimeOutput * (100 - unpaid)) / 100; }
function calculatePayout(bytes32 _info, uint _duration) returns (uint) { uint8 unpaid = unpaidPercentage(_info); CalculatePayout(_info, _duration, hourlyRate, unpaid); uint fullTimeOutput = _duration * hourlyRate / 3600; return (fullTimeOutput * (100 - unpaid)) / 100; }
32,082
34
// Assign tokens to investor with locking period
function assignToken(address _investor,uint256 _tokens) external { // Tokens assigned by only Angel Sales And PE Sales wallets require(msg.sender == walletAddresses[0] || msg.sender == walletAddresses[1]); // Check investor address and tokens.Not allow 0 value require(_investor != address(0) && _tokens > 0); // Check wallet have enough token balance to assign require(_tokens <= balances[msg.sender]); // Debit the tokens from the wallet balances[msg.sender] = safeSub(balances[msg.sender],_tokens); uint256 calCurrentTokens = getPercentageAmount(_tokens, 20); uint256 allocateTokens = safeSub(_tokens, calCurrentTokens); // Initially assign 20% tokens to the investor balances[_investor] = safeAdd(balances[_investor], calCurrentTokens); // Assign tokens to the investor if(msg.sender == walletAddresses[0]){ walletAngelSales[_investor] = safeAdd(walletAngelSales[_investor],allocateTokens); releasedAngelSales[_investor] = safeAdd(releasedAngelSales[_investor], calCurrentTokens); } else if(msg.sender == walletAddresses[1]){ walletPESales[_investor] = safeAdd(walletPESales[_investor],allocateTokens); releasedPESales[_investor] = safeAdd(releasedPESales[_investor], calCurrentTokens); } else{ revert(); } }
function assignToken(address _investor,uint256 _tokens) external { // Tokens assigned by only Angel Sales And PE Sales wallets require(msg.sender == walletAddresses[0] || msg.sender == walletAddresses[1]); // Check investor address and tokens.Not allow 0 value require(_investor != address(0) && _tokens > 0); // Check wallet have enough token balance to assign require(_tokens <= balances[msg.sender]); // Debit the tokens from the wallet balances[msg.sender] = safeSub(balances[msg.sender],_tokens); uint256 calCurrentTokens = getPercentageAmount(_tokens, 20); uint256 allocateTokens = safeSub(_tokens, calCurrentTokens); // Initially assign 20% tokens to the investor balances[_investor] = safeAdd(balances[_investor], calCurrentTokens); // Assign tokens to the investor if(msg.sender == walletAddresses[0]){ walletAngelSales[_investor] = safeAdd(walletAngelSales[_investor],allocateTokens); releasedAngelSales[_investor] = safeAdd(releasedAngelSales[_investor], calCurrentTokens); } else if(msg.sender == walletAddresses[1]){ walletPESales[_investor] = safeAdd(walletPESales[_investor],allocateTokens); releasedPESales[_investor] = safeAdd(releasedPESales[_investor], calCurrentTokens); } else{ revert(); } }
81,594
119
// returns pool rewards for a specific pool and reserve /
function _poolRewards(IDSToken poolToken, IReserveToken reserveToken) private view returns (PoolRewards memory) { PoolRewards memory data; (data.lastUpdateTime, data.rewardPerToken, data.totalClaimedRewards) = _store.poolRewards( poolToken, reserveToken ); return data; }
function _poolRewards(IDSToken poolToken, IReserveToken reserveToken) private view returns (PoolRewards memory) { PoolRewards memory data; (data.lastUpdateTime, data.rewardPerToken, data.totalClaimedRewards) = _store.poolRewards( poolToken, reserveToken ); return data; }
48,889
190
// function requestMint(uint256 vaultId, uint256[] memory nftIds) public payable virtual nonReentrant
// { // onlyOwnerIfPaused(1); // require(store.allowMintRequests(vaultId), "1"); // for (uint256 i = 0; i < nftIds.length; i = i.add(1)) { // if (vaultId > 6 && vaultId < 10) { // KittyCoreAlt kittyCoreAlt = // KittyCoreAlt(store.nftAddress(vaultId)); // kittyCoreAlt.transferFrom(msg.sender, address(this), nftIds[i]); // } else { // store.nft(vaultId).safeTransferFrom( // msg.sender, // address(this), // nftIds[i] // ); // } // store.setRequester(vaultId, nftIds[i], msg.sender); // } // emit MintRequested(vaultId, nftIds, msg.sender); // }
// { // onlyOwnerIfPaused(1); // require(store.allowMintRequests(vaultId), "1"); // for (uint256 i = 0; i < nftIds.length; i = i.add(1)) { // if (vaultId > 6 && vaultId < 10) { // KittyCoreAlt kittyCoreAlt = // KittyCoreAlt(store.nftAddress(vaultId)); // kittyCoreAlt.transferFrom(msg.sender, address(this), nftIds[i]); // } else { // store.nft(vaultId).safeTransferFrom( // msg.sender, // address(this), // nftIds[i] // ); // } // store.setRequester(vaultId, nftIds[i], msg.sender); // } // emit MintRequested(vaultId, nftIds, msg.sender); // }
43,300
16
// Change current governor/_newGovernor Address of the new governor
function changeGovernor(address _newGovernor) external { require(_newGovernor != address(0), "1n"); requireGovernor(msg.sender); if (networkGovernor != _newGovernor) { networkGovernor = _newGovernor; emit NewGovernor(_newGovernor); }
function changeGovernor(address _newGovernor) external { require(_newGovernor != address(0), "1n"); requireGovernor(msg.sender); if (networkGovernor != _newGovernor) { networkGovernor = _newGovernor; emit NewGovernor(_newGovernor); }
28,836
1,037
// Revert with an error when attempting to set a new potential owner that is already set. /
error NewPotentialOwnerAlreadySet(address conduit, address newPotentialOwner);
error NewPotentialOwnerAlreadySet(address conduit, address newPotentialOwner);
23,893
29
// No rewards during unstaking period
if (userInfo.unstaking) { return (rewardAmount, iftBonusAmount, iftPoolRewardAmount); }
if (userInfo.unstaking) { return (rewardAmount, iftBonusAmount, iftPoolRewardAmount); }
21,899
93
// with rounding of last digit
uint _quotient = ((_numerator / denominator) + 5) / 10; return _quotient;
uint _quotient = ((_numerator / denominator) + 5) / 10; return _quotient;
50,753
456
// trade source tokens to BNT (while accepting any return amount)
TradeResult memory targetHop1 = _tradeBNT( contextId, tokens.sourceToken, false,
TradeResult memory targetHop1 = _tradeBNT( contextId, tokens.sourceToken, false,
56,420
8
// Set the base URI baseURI_ (string calldata) base URI /
function setBaseURI(string calldata baseURI_) external onlyOwner { _setBaseURI(baseURI_); }
function setBaseURI(string calldata baseURI_) external onlyOwner { _setBaseURI(baseURI_); }
39,302
2
// Sequencer-Inbox state accumulator
bytes32[] public override inboxAccs;
bytes32[] public override inboxAccs;
67,222
50
// Returns true if the given player does not need to be unlocked to claim their bonus.This is true when they were the last player to click EtherButton in the previous round.That player deserves freebies for losing. So, they get their bonus unlocked early. /
function getIsBonusUnlockExempt(uint roundId, address player) public view returns (bool) { return Rounds[roundId].activePlayer == player; }
function getIsBonusUnlockExempt(uint roundId, address player) public view returns (bool) { return Rounds[roundId].activePlayer == player; }
38,649
5
// This function indicates if the policy of the given contract address is violated or not.If the given contract address is not being monitored by the trusted oracle in this policy,then this function will always return false even if the policy is violated. It is the responsibilityof the pool owner to make sure that this contract address is being monitored by the oracle. _contractAddress - The address of the contract for which the policy status is to be checked.return True if the policy is violated, false otherwise. /
function isViolated(address _contractAddress) external view returns(bool) { return policyViolated[_contractAddress]; }
function isViolated(address _contractAddress) external view returns(bool) { return policyViolated[_contractAddress]; }
40,370
37
// Function to set the lateInterestPremium during a refinance.lateInterestPremium_ The new value for lateInterestPremium. /
function setLateInterestPremium(uint256 lateInterestPremium_) external;
function setLateInterestPremium(uint256 lateInterestPremium_) external;
42,452
53
// set crowdsale token
crowdSaleToken = ERC20Token(_tokenAddress);
crowdSaleToken = ERC20Token(_tokenAddress);
23,384
19
// 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 remaining gas). Requirements: - The divisor cannot be zero. /
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; }
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; }
7,292
23
// Returns URI for the token.
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require(_exists(_tokenId), "RT: invalid token"); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI,_tokenId.toString())) : ""; }
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require(_exists(_tokenId), "RT: invalid token"); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI,_tokenId.toString())) : ""; }
28,126
6
// Returns the amount of tokens owned by `account`./
function balanceOf(address account) external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
4,367
4
// Brendan Asselstine Provides basic fixed point math calculations. This library calculates integer fractions by scaling values by 1e18 then performing standard integer math. /
library FixedPoint { using OpenZeppelinSafeMath_V3_3_0 for uint256; // The scale to use for fixed point numbers. Same as Ether for simplicity. uint256 internal constant SCALE = 1e18; /** * Calculates a Fixed18 mantissa given the numerator and denominator * * The mantissa = (numerator * 1e18) / denominator * * @param numerator The mantissa numerator * @param denominator The mantissa denominator * @return The mantissa of the fraction */ function calculateMantissa(uint256 numerator, uint256 denominator) internal pure returns (uint256) { uint256 mantissa = numerator.mul(SCALE); mantissa = mantissa.div(denominator); return mantissa; } /** * Multiplies a Fixed18 number by an integer. * * @param b The whole integer to multiply * @param mantissa The Fixed18 number * @return An integer that is the result of multiplying the params. */ function multiplyUintByMantissa(uint256 b, uint256 mantissa) internal pure returns (uint256) { uint256 result = mantissa.mul(b); result = result.div(SCALE); return result; } /** * Divides an integer by a fixed point 18 mantissa * * @param dividend The integer to divide * @param mantissa The fixed point 18 number to serve as the divisor * @return An integer that is the result of dividing an integer by a fixed point 18 mantissa */ function divideUintByMantissa(uint256 dividend, uint256 mantissa) internal pure returns (uint256) { uint256 result = SCALE.mul(dividend); result = result.div(mantissa); return result; } }
library FixedPoint { using OpenZeppelinSafeMath_V3_3_0 for uint256; // The scale to use for fixed point numbers. Same as Ether for simplicity. uint256 internal constant SCALE = 1e18; /** * Calculates a Fixed18 mantissa given the numerator and denominator * * The mantissa = (numerator * 1e18) / denominator * * @param numerator The mantissa numerator * @param denominator The mantissa denominator * @return The mantissa of the fraction */ function calculateMantissa(uint256 numerator, uint256 denominator) internal pure returns (uint256) { uint256 mantissa = numerator.mul(SCALE); mantissa = mantissa.div(denominator); return mantissa; } /** * Multiplies a Fixed18 number by an integer. * * @param b The whole integer to multiply * @param mantissa The Fixed18 number * @return An integer that is the result of multiplying the params. */ function multiplyUintByMantissa(uint256 b, uint256 mantissa) internal pure returns (uint256) { uint256 result = mantissa.mul(b); result = result.div(SCALE); return result; } /** * Divides an integer by a fixed point 18 mantissa * * @param dividend The integer to divide * @param mantissa The fixed point 18 number to serve as the divisor * @return An integer that is the result of dividing an integer by a fixed point 18 mantissa */ function divideUintByMantissa(uint256 dividend, uint256 mantissa) internal pure returns (uint256) { uint256 result = SCALE.mul(dividend); result = result.div(mantissa); return result; } }
47,583
7
// set usdc address
function setUSDCAddress(address _usdcAddress) external onlyOwner { usdcAddress = _usdcAddress; }
function setUSDCAddress(address _usdcAddress) external onlyOwner { usdcAddress = _usdcAddress; }
17,961
91
// Function to create a new Group for the user _groupName describes the name of the group /
function createGroup(string memory _groupName)
function createGroup(string memory _groupName)
57,610
268
// internal owner
}
}
28,290
34
// x is now in the range (-42, 136)1e18. Convert to (-42, 136)296 for more intermediate precision and a binary basis. This base conversion is a multiplication by 1e18 / 296 = 518 / 278.
x = (x << 78) / 5**18;
x = (x << 78) / 5**18;
21,866
374
// ... defined by owner of dpass token
mapping(address => bool) redeemFeeToken; // tokens allowed to pay redeem fee with TrustedFeeCalculator public fca; // fee calculator contract address payable public liq; // contract providing DPT liquidity to pay for fee address payable public wal; // wallet address, where we keep all the tokens we received as fee address public burner; // contract where accured fee of DPT is stored before being burned TrustedAsm public asm; // Asset Management contract uint256 public fixFee; // Fixed part of fee charged for buying 18 decimals precision in base currency uint256 public varFee; // Variable part of fee charged for buying 18 decimals precision in base currency uint256 public profitRate; // the percentage of profit that is burned on all fees received. ...
mapping(address => bool) redeemFeeToken; // tokens allowed to pay redeem fee with TrustedFeeCalculator public fca; // fee calculator contract address payable public liq; // contract providing DPT liquidity to pay for fee address payable public wal; // wallet address, where we keep all the tokens we received as fee address public burner; // contract where accured fee of DPT is stored before being burned TrustedAsm public asm; // Asset Management contract uint256 public fixFee; // Fixed part of fee charged for buying 18 decimals precision in base currency uint256 public varFee; // Variable part of fee charged for buying 18 decimals precision in base currency uint256 public profitRate; // the percentage of profit that is burned on all fees received. ...
26,901
177
// Calculate the index of the last item in the array
uint256 userIndex = _stakeholders.length - 1;
uint256 userIndex = _stakeholders.length - 1;
24,369
173
// Price of each Miss
uint256 private _price = 0.04 ether;
uint256 private _price = 0.04 ether;
61,654
21
// Emitted every time `bridge` is called /
event Bridge(
event Bridge(
32,176