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
118
// set the threshold % for re-evaluation of the lStable provided across all Coverage pools : access by owner/threshold uint256 is the reevaluatation threshold
function setRebalancingThreshold(uint256 threshold) external;
function setRebalancingThreshold(uint256 threshold) external;
15,003
19
// _ETH,
_isFeeEnabled, address(feeManager) );
_isFeeEnabled, address(feeManager) );
50,881
92
// Transfers all Ether held by the contract to the owner.
function reclaimEther() external onlyAdmin { msg.sender.transfer(address(this).balance); }
function reclaimEther() external onlyAdmin { msg.sender.transfer(address(this).balance); }
56,753
270
// Overloaded version of the transferFrom function _from sender of transfer _to receiver of transfer _value value of transfer _data data to indicate validationreturn bool success /
function transferFromWithData(address _from, address _to, uint256 _value, bytes _data) public returns(bool) { require(_updateTransfer(_from, _to, _value, _data), "Transfer invalid"); require(super.transferFrom(_from, _to, _value)); return true; }
function transferFromWithData(address _from, address _to, uint256 _value, bytes _data) public returns(bool) { require(_updateTransfer(_from, _to, _value, _data), "Transfer invalid"); require(super.transferFrom(_from, _to, _value)); return true; }
44,828
153
// update total token supply history
__updateHistory(totalSupplyHistory, add, _value);
__updateHistory(totalSupplyHistory, add, _value);
50,081
101
// Quick swap low gas method for pool swaps
function deposit(uint256 _amount) external nonReentrant
function deposit(uint256 _amount) external nonReentrant
65,877
284
// URI returned from parent just returns base URI
return string(abi.encodePacked(super.uri(0), _contractURIHash));
return string(abi.encodePacked(super.uri(0), _contractURIHash));
80,777
5
// Look for any reachable, impermissible opcodes.
bool reachable = true; for (uint256 i = 0; i < extcode.length; i++) { uint8 op = uint8(extcode[i]);
bool reachable = true; for (uint256 i = 0; i < extcode.length; i++) { uint8 op = uint8(extcode[i]);
23,937
52
// Called when Ether is sent and the call data is empty.
receive() external payable {} /// PUBLIC CONSTANT FUNCTIONS /// /// @inheritdoc IPRBProxy function getPermission( address envoy, address target, bytes4 selector ) external view returns (bool) { return permissions[envoy][target][selector]; }
receive() external payable {} /// PUBLIC CONSTANT FUNCTIONS /// /// @inheritdoc IPRBProxy function getPermission( address envoy, address target, bytes4 selector ) external view returns (bool) { return permissions[envoy][target][selector]; }
53,912
293
// add this control token artist to the unique creator list for that control token
uniqueTokenCreators[controlTokenId].push(controlTokenArtists[i]);
uniqueTokenCreators[controlTokenId].push(controlTokenArtists[i]);
15,325
145
// Hook that is called after any transfer of tokens. This includesminting and burning. Calling conditions: - when `from` and `to` are both non-zero.- `from` and `to` are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adocusing-hooks[Using Hooks]. /
function _afterTokenTransfer( address from, address to, uint256 tokenId
function _afterTokenTransfer( address from, address to, uint256 tokenId
19,215
47
// Transfer ETH and return the success status. This function only forwards 30,000 gas to the callee. /
function _safeTransferETH(address to, uint256 value) internal returns (bool)
function _safeTransferETH(address to, uint256 value) internal returns (bool)
42,060
19
// Validations
IPoTypes.Po memory po = poStorage.getPo(poNumber); validatePoItem(po, poItemNumber, IPoTypes.PoItemStatus.Created);
IPoTypes.Po memory po = poStorage.getPo(poNumber); validatePoItem(po, poItemNumber, IPoTypes.PoItemStatus.Created);
10,585
205
// This contains all pre-ICO addresses, and their prices (weis per token)
mapping (address => uint) public preicoAddresses;
mapping (address => uint) public preicoAddresses;
23,200
32
// whether an address is permitted to perform burn operations.
mapping(address => bool) public isBurner;
mapping(address => bool) public isBurner;
41,546
31
// Deposittokens to FlipperVault for FLIPPER allocation.
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; massUpdatePools(); // Transfer pending tokens // to user updateAndPayOutPending(_pid, msg.sender); //Transfer in the amounts from user // save gas if(_amount > 0) { pool.token.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); } user.rewardDebt = user.amount.mul(pool.accFlipperPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); }
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; massUpdatePools(); // Transfer pending tokens // to user updateAndPayOutPending(_pid, msg.sender); //Transfer in the amounts from user // save gas if(_amount > 0) { pool.token.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); } user.rewardDebt = user.amount.mul(pool.accFlipperPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); }
9,468
58
// First, allow all fees to implement settle()
uint256 gav = __settleFees( _comptrollerProxy, vaultProxy, fees, _hook, _settlementData, _gavOrZero );
uint256 gav = __settleFees( _comptrollerProxy, vaultProxy, fees, _hook, _settlementData, _gavOrZero );
38,661
139
// PUBLIC FACING: Release 10% dev share from daily dividends - destined for the token on the tron ​​network /
function xfFlush() external
function xfFlush() external
28,205
143
// // ArrayUtils Project Erax Developers /
library ArrayUtils { /** * Replace bytes in an array with bytes in another array, guarded by a bitmask * Efficiency of this function is a bit unpredictable because of the EVM's word-specific model (arrays under 32 bytes will be slower) * * @dev Mask must be the size of the byte array. A nonzero byte means the byte array can be changed. * @param array The original array * @param desired The target array * @param mask The mask specifying which bits can be changed * return The updated byte array (the parameter will be modified inplace) */ function guardedArrayReplace(bytes memory array, bytes memory desired, bytes memory mask) internal pure { require(array.length == desired.length,"2"); require(array.length == mask.length,"3"); uint words = array.length / 0x20; uint index = words * 0x20; assert(index / 0x20 == words); uint i; for (i = 0; i < words; i++) { /* Conceptually: array[i] = (!mask[i] && array[i]) || (mask[i] && desired[i]), bitwise in word chunks. */ assembly { let commonIndex := mul(0x20, add(1, i)) let maskValue := mload(add(mask, commonIndex)) mstore(add(array, commonIndex), or(and(not(maskValue), mload(add(array, commonIndex))), and(maskValue, mload(add(desired, commonIndex))))) } } /* Deal with the last section of the byte array. */ if (words > 0) { /* This overlaps with bytes already set but is still more efficient than iterating through each of the remaining bytes individually. */ i = words; assembly { let commonIndex := mul(0x20, add(1, i)) let maskValue := mload(add(mask, commonIndex)) mstore(add(array, commonIndex), or(and(not(maskValue), mload(add(array, commonIndex))), and(maskValue, mload(add(desired, commonIndex))))) } } else { /* If the byte array is shorter than a word, we must unfortunately do the whole thing bytewise. (bounds checks could still probably be optimized away in assembly, but this is a rare case) */ for (i = index; i < array.length; i++) { array[i] = ((mask[i] ^ 0xff) & array[i]) | (mask[i] & desired[i]); } } } /** * Test if two arrays are equal * Source: https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol * * @dev Arrays must be of equal length, otherwise will return false * @param a First array * @param b Second array * @return Whether or not all bytes in the arrays are equal */ function arrayEq(bytes memory a, bytes memory b) internal pure returns (bool) { bool success = true; assembly { let length := mload(a) // if lengths don't match the arrays are not equal switch eq(length, mload(b)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(a, 0x20) let end := add(mc, length) for { let cc := add(b, 0x20) // the next line is the loop condition: // while(uint(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } /** * Unsafe write byte array into a memory location * * @param index Memory location * @param source Byte array to write * @return End memory index */ function unsafeWriteBytes(uint index, bytes memory source) internal pure returns (uint) { if (source.length > 0) { assembly { let length := mload(source) let end := add(source, add(0x20, length)) let arrIndex := add(source, 0x20) let tempIndex := index for { } eq(lt(arrIndex, end), 1) { arrIndex := add(arrIndex, 0x20) tempIndex := add(tempIndex, 0x20) } { mstore(tempIndex, mload(arrIndex)) } index := add(index, length) } } return index; }
library ArrayUtils { /** * Replace bytes in an array with bytes in another array, guarded by a bitmask * Efficiency of this function is a bit unpredictable because of the EVM's word-specific model (arrays under 32 bytes will be slower) * * @dev Mask must be the size of the byte array. A nonzero byte means the byte array can be changed. * @param array The original array * @param desired The target array * @param mask The mask specifying which bits can be changed * return The updated byte array (the parameter will be modified inplace) */ function guardedArrayReplace(bytes memory array, bytes memory desired, bytes memory mask) internal pure { require(array.length == desired.length,"2"); require(array.length == mask.length,"3"); uint words = array.length / 0x20; uint index = words * 0x20; assert(index / 0x20 == words); uint i; for (i = 0; i < words; i++) { /* Conceptually: array[i] = (!mask[i] && array[i]) || (mask[i] && desired[i]), bitwise in word chunks. */ assembly { let commonIndex := mul(0x20, add(1, i)) let maskValue := mload(add(mask, commonIndex)) mstore(add(array, commonIndex), or(and(not(maskValue), mload(add(array, commonIndex))), and(maskValue, mload(add(desired, commonIndex))))) } } /* Deal with the last section of the byte array. */ if (words > 0) { /* This overlaps with bytes already set but is still more efficient than iterating through each of the remaining bytes individually. */ i = words; assembly { let commonIndex := mul(0x20, add(1, i)) let maskValue := mload(add(mask, commonIndex)) mstore(add(array, commonIndex), or(and(not(maskValue), mload(add(array, commonIndex))), and(maskValue, mload(add(desired, commonIndex))))) } } else { /* If the byte array is shorter than a word, we must unfortunately do the whole thing bytewise. (bounds checks could still probably be optimized away in assembly, but this is a rare case) */ for (i = index; i < array.length; i++) { array[i] = ((mask[i] ^ 0xff) & array[i]) | (mask[i] & desired[i]); } } } /** * Test if two arrays are equal * Source: https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol * * @dev Arrays must be of equal length, otherwise will return false * @param a First array * @param b Second array * @return Whether or not all bytes in the arrays are equal */ function arrayEq(bytes memory a, bytes memory b) internal pure returns (bool) { bool success = true; assembly { let length := mload(a) // if lengths don't match the arrays are not equal switch eq(length, mload(b)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(a, 0x20) let end := add(mc, length) for { let cc := add(b, 0x20) // the next line is the loop condition: // while(uint(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } /** * Unsafe write byte array into a memory location * * @param index Memory location * @param source Byte array to write * @return End memory index */ function unsafeWriteBytes(uint index, bytes memory source) internal pure returns (uint) { if (source.length > 0) { assembly { let length := mload(source) let end := add(source, add(0x20, length)) let arrIndex := add(source, 0x20) let tempIndex := index for { } eq(lt(arrIndex, end), 1) { arrIndex := add(arrIndex, 0x20) tempIndex := add(tempIndex, 0x20) } { mstore(tempIndex, mload(arrIndex)) } index := add(index, length) } } return index; }
4,777
21
// DEPLOYMENT ACCOUNT FUNCTION TO UPDATE FEE RATE FOR EXECUTIONS
function updateRate(bytes32 _tradePair, uint _rate, ITradePairs.RateType _rateType) public { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "E-OACC-04"); tradePairs.updateRate(_tradePair, _rate, _rateType); }
function updateRate(bytes32 _tradePair, uint _rate, ITradePairs.RateType _rateType) public { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "E-OACC-04"); tradePairs.updateRate(_tradePair, _rate, _rateType); }
46,130
19
// call ecmul precompile inputs are: x, y, scalar
success := staticcall (not(0), 0x07, i, 0x60, retP, 0x40)
success := staticcall (not(0), 0x07, i, 0x60, retP, 0x40)
47,975
55
// Function to transfer a token (if applicable).Transfers `tokenId` from `from` to `to`.from The Ethereum address of the user that own the token.to The Ethereum address of the user that could receive the token.tokenId The ID of the BadgeToken./
function _transfer(address from, address to, uint256 tokenId) internal override { uint tokenIdex = tokenId - 1; // Check if the token can be transfered require(badgeDefinitionFactory.isBadgeTransferable(_badgeTokens[tokenIdex].badgeDefinitionId), string(abi.encodePacked(badgeTokenSymbol, ": this token is bind to its original owner", _badgeTokens[tokenIdex].originalOwner))); // Transfer the token (if applicable) super._transfer(from, to, tokenId); }
function _transfer(address from, address to, uint256 tokenId) internal override { uint tokenIdex = tokenId - 1; // Check if the token can be transfered require(badgeDefinitionFactory.isBadgeTransferable(_badgeTokens[tokenIdex].badgeDefinitionId), string(abi.encodePacked(badgeTokenSymbol, ": this token is bind to its original owner", _badgeTokens[tokenIdex].originalOwner))); // Transfer the token (if applicable) super._transfer(from, to, tokenId); }
24,728
151
// Deletes the token with the provided ID. _tokenId uint256 ID of the token. /
function deleteToken(uint256 _tokenId) public onlyTokenOwner(_tokenId) { _burn(msg.sender, _tokenId); }
function deleteToken(uint256 _tokenId) public onlyTokenOwner(_tokenId) { _burn(msg.sender, _tokenId); }
44,245
13
// If x > 1, then we compute the fraction part of log2(x), which is larger than 0.
if (x > FIXED_1) { for (uint8 i = MAX_PRECISION; i > 0; --i) { x = (x * x) / FIXED_1; // now 1 < x < 4 if (x >= FIXED_2) { x >>= 1; // now 1 < x < 2 res += ONE << (i - 1); }
if (x > FIXED_1) { for (uint8 i = MAX_PRECISION; i > 0; --i) { x = (x * x) / FIXED_1; // now 1 < x < 4 if (x >= FIXED_2) { x >>= 1; // now 1 < x < 2 res += ONE << (i - 1); }
56,342
12
// public metadata locked flag
bool public locked;
bool public locked;
4,732
8
// Pack NFT address
PackNFT public immutable packNFT;
PackNFT public immutable packNFT;
21,411
72
// Reset the variables
uint256 _i = 0; uint256 _j = totalBuyers - 1; uint256 _n = 0;
uint256 _i = 0; uint256 _j = totalBuyers - 1; uint256 _n = 0;
5,735
5
// eter key ID parameters
bool isMember; string alias; string whisperID; string memberDescription; string mImagelink; uint memberCommunity; bool isBank; bool isCommune;
bool isMember; string alias; string whisperID; string memberDescription; string mImagelink; uint memberCommunity; bool isBank; bool isCommune;
12,156
300
// Retrieve and store the underlying price from the oracle This method can be called by anyone after expiration but cannot be calledmore than once. In practice it should be called as soon as possible after theexpiration time. /
function settle() external nonReentrant { require(isExpired(), "Cannot be called before expiry"); require(!isSettled, "Already settled"); // fetch expiry price from oracle isSettled = true; expiryPrice = oracle.getPrice(); require(expiryPrice > 0, "Price from oracle must be > 0"); // update cached payoff and pool value lastPayoff = getCurrentPayoff(); poolValue = baseToken.uniBalanceOf(address(this)).sub(lastPayoff); emit Settle(expiryPrice); }
function settle() external nonReentrant { require(isExpired(), "Cannot be called before expiry"); require(!isSettled, "Already settled"); // fetch expiry price from oracle isSettled = true; expiryPrice = oracle.getPrice(); require(expiryPrice > 0, "Price from oracle must be > 0"); // update cached payoff and pool value lastPayoff = getCurrentPayoff(); poolValue = baseToken.uniBalanceOf(address(this)).sub(lastPayoff); emit Settle(expiryPrice); }
22,711
1
// Requests randomness from a user-provided seed /
function getRandomNumber() external;
function getRandomNumber() external;
17,738
18
// Tradescrow Fee Sharing v1.0.0@DirtyCajunRice/
contract TradescrowFeeSharing { // Use SafeERC20 for best practice using SafeERC20 for IERC20; uint256 private _totalShare; uint256 private _totalReleased; mapping(address => uint256) private _share; mapping(address => uint256) private _released; address[] private _beneficiary; mapping(SafeERC20 => uint256) private _erc20TotalReleased; mapping(SafeERC20 => mapping(address => uint256)) private _erc20Released; struct ScalingCondition { } // Beneficiary struct to hold the details of a single beneficiary struct Beneficiary { address payable addr; uint256 baseShare; bool scaling; ScalingCondition[] _conditions; } event BeneficiaryAdded( address indexed addr, uint256 indexed baseShare, bool indexed scaling, ScalingCondition[] conditions ); event PaymentReleased(address indexed to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address indexed to, uint256 amount); event PaymentReceived(address indexed from, uint256 amount); constructor(Beneficiary[] memory beneficiaries) payable { require(beneficiaries.length > 0, "TradescrowFeeSharing: no beneficiaries"); for (uint256 i = 0; i < beneficiaries.length; i++) { require(beneficiaries[i].baseShare > 0, "TradescrowFeeSharing: beneficiary missing base share"); if (beneficiaries[i].scaling) { require(beneficiaries[i].conditions.length > 0, "TradescrowFeeSharing: beneficiary missing conditions"); } } for (uint256 i = 0; i < beneficiaries.length; i++) { _addBeneficiary(beneficiaries[i]); } } /** * @dev The ONE received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive ONE without triggering this function. This only affects the * reliability of the events, and not the actual splitting of ONE. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total share held by beneficiaries. */ function totalShare() public view returns (uint256) { return _totalShare; } /** * @dev Getter for the total amount of ONE already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of a SafeERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of share held by an account. */ function share(address account) public view returns (uint256) { return _share[account]; } /** * @dev Getter for the amount of ONE already released to a beneficiary. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * SafeERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the beneficiary number `index`. */ function beneficiary(uint256 index) public view returns (address) { return _beneficiary[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new beneficiary to the contract. * @param account The address of the beneficiary to add. * @param share_ The number of percent owned by the payee. */ function _addBeneficiary(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
contract TradescrowFeeSharing { // Use SafeERC20 for best practice using SafeERC20 for IERC20; uint256 private _totalShare; uint256 private _totalReleased; mapping(address => uint256) private _share; mapping(address => uint256) private _released; address[] private _beneficiary; mapping(SafeERC20 => uint256) private _erc20TotalReleased; mapping(SafeERC20 => mapping(address => uint256)) private _erc20Released; struct ScalingCondition { } // Beneficiary struct to hold the details of a single beneficiary struct Beneficiary { address payable addr; uint256 baseShare; bool scaling; ScalingCondition[] _conditions; } event BeneficiaryAdded( address indexed addr, uint256 indexed baseShare, bool indexed scaling, ScalingCondition[] conditions ); event PaymentReleased(address indexed to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address indexed to, uint256 amount); event PaymentReceived(address indexed from, uint256 amount); constructor(Beneficiary[] memory beneficiaries) payable { require(beneficiaries.length > 0, "TradescrowFeeSharing: no beneficiaries"); for (uint256 i = 0; i < beneficiaries.length; i++) { require(beneficiaries[i].baseShare > 0, "TradescrowFeeSharing: beneficiary missing base share"); if (beneficiaries[i].scaling) { require(beneficiaries[i].conditions.length > 0, "TradescrowFeeSharing: beneficiary missing conditions"); } } for (uint256 i = 0; i < beneficiaries.length; i++) { _addBeneficiary(beneficiaries[i]); } } /** * @dev The ONE received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive ONE without triggering this function. This only affects the * reliability of the events, and not the actual splitting of ONE. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total share held by beneficiaries. */ function totalShare() public view returns (uint256) { return _totalShare; } /** * @dev Getter for the total amount of ONE already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of a SafeERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of share held by an account. */ function share(address account) public view returns (uint256) { return _share[account]; } /** * @dev Getter for the amount of ONE already released to a beneficiary. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * SafeERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the beneficiary number `index`. */ function beneficiary(uint256 index) public view returns (address) { return _beneficiary[index]; } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance + totalReleased(); uint256 payment = _pendingPayment(account, totalReceived, released(account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] += payment; _totalReleased += payment; Address.sendValue(account, payment); emit PaymentReleased(account, payment); } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) private view returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new beneficiary to the contract. * @param account The address of the beneficiary to add. * @param share_ The number of percent owned by the payee. */ function _addBeneficiary(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
43,133
67
// setup temp var for player eth
uint256 _eth;
uint256 _eth;
34,788
374
// It's a cfolioItem itself, only calculate underlying value
tokenIds = new uint256[](1); tokenIds[0] = sftTokenId; tokenIdsLength = 1;
tokenIds = new uint256[](1); tokenIds[0] = sftTokenId; tokenIdsLength = 1;
56,038
38
// The delay before voting on a proposal may take place, once proposed
function votingDelay() public pure returns (uint256) { return 1; } // 1 block
function votingDelay() public pure returns (uint256) { return 1; } // 1 block
35,668
122
// Modifies a function to run only when the caller is the operator account.
modifier onlyOperator() { require(_msgSender() == operator, "operator only"); _; }
modifier onlyOperator() { require(_msgSender() == operator, "operator only"); _; }
30,464
39
// update the token's previous owner
cryptoboy.previousOwner = cryptoboy.currentOwner;
cryptoboy.previousOwner = cryptoboy.currentOwner;
10,022
21
// detach many addresses association between addresses and their respective users_ /
function detachManyAddresses(address[] memory _addresses) override public onlyOperator
function detachManyAddresses(address[] memory _addresses) override public onlyOperator
23,369
28
// Unsynthesize and final call on second chain Token -> sToken on a first chain -> final token on a second chain _stableBridgingFee Number of tokens to send to bridge (fee) _externalID the metaBurn transaction that was received from the event when it was originally called metaBurn on the Synthesis contract _to The address to receive tokens _amount Number of tokens to unsynthesize _rToken The address of the token to unsynthesize _finalReceiveSide router for final call _finalCalldata encoded call of a final function _finalOffset offset to patch _amount to _finalCalldata /
function metaUnsynthesize( uint256 _stableBridgingFee, bytes32 _externalID, address _to, uint256 _amount, address _rToken, address _finalReceiveSide, bytes memory _finalCalldata, uint256 _finalOffset
function metaUnsynthesize( uint256 _stableBridgingFee, bytes32 _externalID, address _to, uint256 _amount, address _rToken, address _finalReceiveSide, bytes memory _finalCalldata, uint256 _finalOffset
24,693
11
// Prevent unneccessary redemptions that could adversely affect the GR price
require(Synth.synth_price() <= redeem_price_threshold || !priceVerify, "Synth price too high"); _;
require(Synth.synth_price() <= redeem_price_threshold || !priceVerify, "Synth price too high"); _;
36,866
25
// mapping for owner of token
mapping(uint256 => address) public token;
mapping(uint256 => address) public token;
4,166
414
// SPDX-License-Identifier: Unlicense
interface INFT { function mint(address _to, uint256 _count) payable external; function presaleMint(address _to, uint256 _count) payable external; }
interface INFT { function mint(address _to, uint256 _count) payable external; function presaleMint(address _to, uint256 _count) payable external; }
45,590
154
// See {IERC721Enumerable-totalSupply}./
function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; }
function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; }
58,378
84
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path);
11,446
123
// calcSingleInGivenPoolOut tAi = tokenAmountIn(pS + pAo)\ /1\\pS = poolSupply || ---------| ^ | --------- ||bI - bI pAo = poolAmountOut\\pS/ \(wI / tW)bI = balanceIntAi =--------------------------------------------wI = weightIn/wI\tW = totalWeight|1 - ----| sF sF = swapFee \tW/ /
{ uint normalizedWeight = bdiv(tokenWeightIn, totalWeight); uint newPoolSupply = badd(poolSupply, poolAmountOut); uint poolRatio = bdiv(newPoolSupply, poolSupply); //uint newBalTi = poolRatio^(1/weightTi) * balTi; uint boo = bdiv(BONE, normalizedWeight); uint tokenInRatio = bpow(poolRatio, boo); uint newTokenBalanceIn = bmul(tokenInRatio, tokenBalanceIn); uint tokenAmountInAfterFee = bsub(newTokenBalanceIn, tokenBalanceIn); // Do reverse order of fees charged in joinswap_ExternAmountIn, this way // ``` pAo == joinswap_ExternAmountIn(Ti, joinswap_PoolAmountOut(pAo, Ti)) ``` //uint tAi = tAiAfterFee / (1 - (1-weightTi) * swapFee) ; uint zar = bmul(bsub(BONE, normalizedWeight), swapFee); tokenAmountIn = bdiv(tokenAmountInAfterFee, bsub(BONE, zar)); return tokenAmountIn; }
{ uint normalizedWeight = bdiv(tokenWeightIn, totalWeight); uint newPoolSupply = badd(poolSupply, poolAmountOut); uint poolRatio = bdiv(newPoolSupply, poolSupply); //uint newBalTi = poolRatio^(1/weightTi) * balTi; uint boo = bdiv(BONE, normalizedWeight); uint tokenInRatio = bpow(poolRatio, boo); uint newTokenBalanceIn = bmul(tokenInRatio, tokenBalanceIn); uint tokenAmountInAfterFee = bsub(newTokenBalanceIn, tokenBalanceIn); // Do reverse order of fees charged in joinswap_ExternAmountIn, this way // ``` pAo == joinswap_ExternAmountIn(Ti, joinswap_PoolAmountOut(pAo, Ti)) ``` //uint tAi = tAiAfterFee / (1 - (1-weightTi) * swapFee) ; uint zar = bmul(bsub(BONE, normalizedWeight), swapFee); tokenAmountIn = bdiv(tokenAmountInAfterFee, bsub(BONE, zar)); return tokenAmountIn; }
36,969
11
// /
function checkUpkeep(bytes memory /**checkData */) public view override returns (bool upkeepNeeded, bytes memory /**performData */)
function checkUpkeep(bytes memory /**checkData */) public view override returns (bool upkeepNeeded, bytes memory /**performData */)
18,082
117
// gysr fields
IERC20 private immutable _gysr;
IERC20 private immutable _gysr;
38,107
51
// If the target address is a contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer, and return the magic value `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, the transfer is reverted. Requires the msg.sender to be the owner, approved, or operatorfrom current owner of the tokento address to receive the ownership of the given token IDtokenId uint256 ID of the token to be transferred/
function safeTransferFrom(address from, address to, uint256 tokenId) public { safeTransferFrom(from, to, tokenId, ""); }
function safeTransferFrom(address from, address to, uint256 tokenId) public { safeTransferFrom(from, to, tokenId, ""); }
23,353
44
// Royalties are forwarded to {PaymentSplitter} /
receive() external payable { IGenArtPaymentSplitter(_paymentSplitter).splitPaymentRoyalty{ value: msg.value }(address(this));
receive() external payable { IGenArtPaymentSplitter(_paymentSplitter).splitPaymentRoyalty{ value: msg.value }(address(this));
82,888
396
// Changes the minimum timelock duration for future operations.
* Emits a {MinDelayChange} event. * * Requirements: * * - the caller must be the timelock itself. This can only be achieved by scheduling and later executing * an operation where the timelock is the target and the data is the ABI-encoded call to this function. */ function updateDelay(uint256 newDelay) external virtual { require(msg.sender == address(this), "TimelockController: caller must be timelock"); emit MinDelayChange(_minDelay, newDelay); _minDelay = newDelay; }
* Emits a {MinDelayChange} event. * * Requirements: * * - the caller must be the timelock itself. This can only be achieved by scheduling and later executing * an operation where the timelock is the target and the data is the ABI-encoded call to this function. */ function updateDelay(uint256 newDelay) external virtual { require(msg.sender == address(this), "TimelockController: caller must be timelock"); emit MinDelayChange(_minDelay, newDelay); _minDelay = newDelay; }
11,004
93
// Log this sale
today.soldFromUnreserved = today.soldFromUnreserved.add(askedMoreThanReserved); today.soldFromReserved = today.soldFromReserved.add(useFromReserved); today.fuelBoughtByAddress[beneficiary] = today.fuelBoughtByAddress[beneficiary].add(amountOfHolosAsked); CreditsCreated(beneficiary, msg.value, amountOfHolosAsked);
today.soldFromUnreserved = today.soldFromUnreserved.add(askedMoreThanReserved); today.soldFromReserved = today.soldFromReserved.add(useFromReserved); today.fuelBoughtByAddress[beneficiary] = today.fuelBoughtByAddress[beneficiary].add(amountOfHolosAsked); CreditsCreated(beneficiary, msg.value, amountOfHolosAsked);
39,759
7
// Start the game by calling this function
function startGame() public { require(activated, "The game is not yet activated"); require(curNumPlayers == numPlayers, "Mismatch in number of players."); require( msg.sender == orgAddress, "only the organization can start the game" ); require(block.timestamp-createdTime <= waitTime*1, "Timeout!"); live = true; startTime = block.timestamp; }
function startGame() public { require(activated, "The game is not yet activated"); require(curNumPlayers == numPlayers, "Mismatch in number of players."); require( msg.sender == orgAddress, "only the organization can start the game" ); require(block.timestamp-createdTime <= waitTime*1, "Timeout!"); live = true; startTime = block.timestamp; }
8,459
10
// Looks like some user has paid to this method, this payment is not included in the analytics, but, of course, processed.
iaOnInvested(msg.sender, msg.value, false);
iaOnInvested(msg.sender, msg.value, false);
37,930
11
// Set treasury and fee
changeTreasury(_treasury); changeFee(_shieldFee, _unshieldFee, _nftFee);
changeTreasury(_treasury); changeFee(_shieldFee, _unshieldFee, _nftFee);
17,274
84
// underlying -> chainlink feed see https:docs.chain.link/docs/reference-contracts
mapping (address => address) public priceFeedsUSD; mapping (address => address) public priceFeedsETH;
mapping (address => address) public priceFeedsUSD; mapping (address => address) public priceFeedsETH;
38,896
20
// Set our paused state.
paused = _paused;
paused = _paused;
10,937
16
// - In mappingg The entire storage space is virtually initialized to 0--2 => operation inside whitelist implemented or result is unknown--1 => operation inside whitelist not permitted- 0 => NOT existing in whitelist AKA NOT Allowed- 1 => exist in whitelist and allowed- 2 => exist in whitelist but in quarantine- 3 => exist in whitelist but suspended- 4 => exist in whitelist but disabled- 5 => exist in whitelist but erased
mapping(address => int) private _whitelist;
mapping(address => int) private _whitelist;
29,625
23
// ITEMS /Returns item and all its item positions. /
function fetchItem(uint256 itemId) public view returns (ItemResponse memory) { ISqwidMarketplace.Item memory item = marketplace.fetchItem(itemId); require(item.itemId > 0, "SqwidMarketUtil: Item not found"); return ItemResponse( itemId, item.nftContract, item.tokenId, item.creator, item.sales, _fetchPositionsByItemId(itemId) ); }
function fetchItem(uint256 itemId) public view returns (ItemResponse memory) { ISqwidMarketplace.Item memory item = marketplace.fetchItem(itemId); require(item.itemId > 0, "SqwidMarketUtil: Item not found"); return ItemResponse( itemId, item.nftContract, item.tokenId, item.creator, item.sales, _fetchPositionsByItemId(itemId) ); }
49,367
28
// Transfer tokens from one address to another from_ address The address which you want to send tokens from to_ address The address which you want to transfer to value_ uint the amount of tokens to be transferred /
function transferFrom(address from_, address to_, uint value_) public whenNotLocked returns (bool) { require(to_ != address(0) && value_ <= balances[from_] && value_ <= allowed[from_][msg.sender]); balances[from_] = balances[from_].sub(value_); balances[to_] = balances[to_].add(value_); allowed[from_][msg.sender] = allowed[from_][msg.sender].sub(value_); emit Transfer(from_, to_, value_); return true; }
function transferFrom(address from_, address to_, uint value_) public whenNotLocked returns (bool) { require(to_ != address(0) && value_ <= balances[from_] && value_ <= allowed[from_][msg.sender]); balances[from_] = balances[from_].sub(value_); balances[to_] = balances[to_].add(value_); allowed[from_][msg.sender] = allowed[from_][msg.sender].sub(value_); emit Transfer(from_, to_, value_); return true; }
6,745
19
// Block number that interest was last accrued at /
uint public accrualBlockNumber;
uint public accrualBlockNumber;
14,171
26
// Removes a token from the list of supported tokens./ Deregistration is pending until next cycle.//_token The address of the token to be deregistered.
function deregisterToken(address _token) external onlyOwner { require( registeredTokens.isInList(_token), "ClaimlessRewards: token not registered" ); registeredTokens.remove(_token); // Add to deregistered tokens. This check should always be true. if (!deregisteredTokens.isInList(_token)) { deregisteredTokens.append(_token); } }
function deregisterToken(address _token) external onlyOwner { require( registeredTokens.isInList(_token), "ClaimlessRewards: token not registered" ); registeredTokens.remove(_token); // Add to deregistered tokens. This check should always be true. if (!deregisteredTokens.isInList(_token)) { deregisteredTokens.append(_token); } }
6,058
29
// The total fee is the burned bond and the final fee added together.
uint256 totalFee = finalFee.add(burnedBond); if (totalFee > 0) { request.currency.safeIncreaseAllowance(address(store), totalFee); _getStore().payOracleFeesErc20(address(request.currency), FixedPoint.Unsigned(totalFee)); }
uint256 totalFee = finalFee.add(burnedBond); if (totalFee > 0) { request.currency.safeIncreaseAllowance(address(store), totalFee); _getStore().payOracleFeesErc20(address(request.currency), FixedPoint.Unsigned(totalFee)); }
26,862
4
// Current requirement for hot potatoes
uint256 public spiderReq; uint256 public tadpoleReq; uint256 public squirrelReq;
uint256 public spiderReq; uint256 public tadpoleReq; uint256 public squirrelReq;
38,364
155
// If the low bit is set, multiply in the (many-times-squared) base
realResult = mul(realResult, tempRealBase);
realResult = mul(realResult, tempRealBase);
11,084
10
// sorts a list of values in ascending order/data the list of values to order/ return the ordered values with the corresponding ordered indices/ base implementation provided by https:gist.github.com/subhodi/b3b86cc13ad2636420963e692a4d896f
function sort(uint[] memory data) public returns(Element[] memory) { Element[] memory dataElements = new Element[](data.length); for (uint i=0; i<data.length; i++){ dataElements[i] = Element(i, data[i]); } quickSort(dataElements, int(0), int(dataElements.length - 1)); return dataElements; }
function sort(uint[] memory data) public returns(Element[] memory) { Element[] memory dataElements = new Element[](data.length); for (uint i=0; i<data.length; i++){ dataElements[i] = Element(i, data[i]); } quickSort(dataElements, int(0), int(dataElements.length - 1)); return dataElements; }
41,269
412
// first accrue credit for their old balance
uint256 newCreditBalance = _calculateCreditBalance(from, msg.sender, fromBeforeBalance, 0); if (from != to) {
uint256 newCreditBalance = _calculateCreditBalance(from, msg.sender, fromBeforeBalance, 0); if (from != to) {
36,122
133
// if there is a short option and a long option in the vault, ensure that the long option is able to be used as collateral for the short option _vault the vault to check _vaultDetails vault details structreturn true if long is marginable or false if not /
function _isMarginableLong(MarginVault.Vault memory _vault, VaultDetails memory _vaultDetails) internal pure returns (bool)
function _isMarginableLong(MarginVault.Vault memory _vault, VaultDetails memory _vaultDetails) internal pure returns (bool)
22,414
78
// Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. This method is included for ERC20 compatibility. increaseAllowance and decreaseAllowance should be used instead. Changing an allowance with this method brings the risk that someone may transfer both the old and the new allowance - if they are both greater than zero - if a transfer transaction is mined before the later approve() call is mined.spender The address which will spend the funds.value The amount of tokens to be spent./
function approve(address spender, uint256 value) public whenTokenNotPaused returns (bool)
function approve(address spender, uint256 value) public whenTokenNotPaused returns (bool)
39,799
56
// SimpleToken Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.Note they can later distribute these tokens as they wish using `transfer` and other`ERC20` functions. /
contract Token is ERC20, ERC20Detailed { /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor () public ERC20Detailed("charge", "CHG",8) { _mint(msg.sender,(15000 * (10 ** 8))); } }
contract Token is ERC20, ERC20Detailed { /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor () public ERC20Detailed("charge", "CHG",8) { _mint(msg.sender,(15000 * (10 ** 8))); } }
3,626
220
// tell the burn function to burn 1 of this specific id
values[i] = 1;
values[i] = 1;
27,480
51
// Deletes CLIMB Tokens Sent To Contract /
function takeOutGarbage() external nonReentrant { _checkGarbageCollector(); }
function takeOutGarbage() external nonReentrant { _checkGarbageCollector(); }
3,605
20
// solhint-disable-next-line
(bool success, ) = payable(fundsReceiver).call{value: contractBalance}(
(bool success, ) = payable(fundsReceiver).call{value: contractBalance}(
7,709
9
// for mint functionaccount The address to get the reward.amount The amount of the reward./
function _mint(address account, uint256 amount) internal
function _mint(address account, uint256 amount) internal
43,273
9
// Disable self-destruction of this contract/This operation can not be undone
function disableSelfDestruction() public
function disableSelfDestruction() public
39,951
1
// Address of the bAsset
address addr;
address addr;
31,812
7
// Get the free memory pointer.
let ptr := mload(0x40)
let ptr := mload(0x40)
11,459
118
// add liquidity
_addLiquidity(amountToLiquify, amountBNBLiquidity);
_addLiquidity(amountToLiquify, amountBNBLiquidity);
21,337
214
// return an array of address of all zone present on a zone zone is a mapping COUNTRY => POSTALCODE
function getZoneShop(bytes2 _country, bytes16 _postalcode) public view returns (address[]) { return shopInZone[_country][_postalcode]; }
function getZoneShop(bytes2 _country, bytes16 _postalcode) public view returns (address[]) { return shopInZone[_country][_postalcode]; }
8,483
26
// Returns true if the address is delegated to act on your behalf for a specific token, the token's contract or an entire vault delegate The hotwallet to act on your behalf contract_ The address for the contract you're delegating tokenId The token id for the token you're delegating vault The cold wallet who issued the delegation /
function checkDelegateForToken(
function checkDelegateForToken(
14,213
50
// 基准价格
uint basePrice;
uint basePrice;
81,672
35
// Get true adopted
address adopted = _adopted == address(0) ? _local : _adopted;
address adopted = _adopted == address(0) ? _local : _adopted;
19,220
42
// Returns the address of the ENSRegistrar for the Network./ return address The address the ENSRegistrar resolves to
function getENSRegistrar() public view returns (address);
function getENSRegistrar() public view returns (address);
2,625
69
// Emitted once a stake is scheduled for withdrawal
event StakeUnlocked( address indexed relayManager, address indexed owner, uint256 withdrawBlock );
event StakeUnlocked( address indexed relayManager, address indexed owner, uint256 withdrawBlock );
26,439
44
// Can start minting token after 01.10.2018
require(now >= startMintingData); nextMintPossibleTime = now; canMint = true; emit AllowMinting();
require(now >= startMintingData); nextMintPossibleTime = now; canMint = true; emit AllowMinting();
10,344
78
// The block number whenmining starts.
uint256 public startBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( IToken _token, address _devaddr, uint256 _rewardPerBlock,
uint256 public startBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( IToken _token, address _devaddr, uint256 _rewardPerBlock,
7,620
21
// Handles a pool's reward at the current epoch./This will split the reward between the operator and members,/depositing them into their respective vaults, and update the/accounting needed to allow members to withdraw their individual/rewards./poolId Unique Id of pool./reward received by the pool./membersStake the amount of non-operator delegated stake that/will split thereward./ return operatorReward Portion of `reward` given to the pool operator./ return membersReward Portion of `reward` given to the pool members.
function _syncPoolRewards( bytes32 poolId, uint256 reward, uint256 membersStake ) internal returns (uint256 operatorReward, uint256 membersReward)
function _syncPoolRewards( bytes32 poolId, uint256 reward, uint256 membersStake ) internal returns (uint256 operatorReward, uint256 membersReward)
11,481
46
// Convert Tokens (token) to Tokens (exchange_addr.token) && transfersTokens (exchange_addr.token) to recipient. Allows trades through contracts that were not deployed from the same factory. User specifies maximum input && exact output. tokens_bought Amount of Tokens (token_addr) bought. max_tokens_sold Maximum Tokens (token) sold. max_eth_sold Maximum ETH purchased as intermediary. deadline Time after which this transaction can no longer be executed. recipient The address that receives output ETH. exchange_addr The address of the exchange for the token being purchased.return Amount of Tokens (token) sold. /
function tokenToExchangeTransferOutput(
function tokenToExchangeTransferOutput(
9,009
138
// to avoid of rewardPerToken calculation overflow (see https:sips.synthetix.io/sips/sip-77), we check the reward to be inside a properate range which is 2^256 / 10^18
require(reward < REWARD_OVERFLOW_CHECK, "reward rate will overflow"); rewardRate = reward.div(rewardDuration); lastUpdateTime = startTime; periodFinish = startTime.add(rewardDuration); emit RewardAdded(reward);
require(reward < REWARD_OVERFLOW_CHECK, "reward rate will overflow"); rewardRate = reward.div(rewardDuration); lastUpdateTime = startTime; periodFinish = startTime.add(rewardDuration); emit RewardAdded(reward);
60,445
282
// ================================= Events =================================
event SaleToggle(uint256 moleculeNumber, bool isForSale, uint256 price); event PurchaseEvent(uint256 moleculeNumber, address from, address to, uint256 price); event moleculeBonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime); event moleculeUnbonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime); event moleculeGrown(uint256 moleculeNumber, uint256 newLevel); constructor( address _contractOwner, address _royaltyReceiver,
event SaleToggle(uint256 moleculeNumber, bool isForSale, uint256 price); event PurchaseEvent(uint256 moleculeNumber, address from, address to, uint256 price); event moleculeBonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime); event moleculeUnbonded(uint256 moleculeNumber, address owner, uint256 NodeCreationTime); event moleculeGrown(uint256 moleculeNumber, uint256 newLevel); constructor( address _contractOwner, address _royaltyReceiver,
59,934
85
// can recommit this gives you more chances if no-one else sends the callback (should never happen) still only get a random extra chance
function recommit(uint id) public { Purchase storage p = purchases[id]; require(p.randomness == 0, "randomness already set"); require(block.number >= p.commit.add(uint64(256)), "no need to recommit"); p.commit = getCommitBlock(); emit Recommit(id, p.packType, p.user, p.count, p.lockup); }
function recommit(uint id) public { Purchase storage p = purchases[id]; require(p.randomness == 0, "randomness already set"); require(block.number >= p.commit.add(uint64(256)), "no need to recommit"); p.commit = getCommitBlock(); emit Recommit(id, p.packType, p.user, p.count, p.lockup); }
12,818
101
// message unnecessarily. For custom revert reasons use {tryMod}. 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; }
18,005
6
// Modifies value at location 1
arrayData = x;
arrayData = x;
7,613
763
// res += valcoefficients[187].
res := addmod(res, mulmod(val, /*coefficients[187]*/ mload(0x1ca0), PRIME), PRIME)
res := addmod(res, mulmod(val, /*coefficients[187]*/ mload(0x1ca0), PRIME), PRIME)
21,789
51
// Ensures the caller is the SYSTEM_ADDRESS. See https:openethereum.github.io/wiki/Validator-Set.html
modifier onlySystem() { require(msg.sender == 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE); _; }
modifier onlySystem() { require(msg.sender == 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE); _; }
7,505
256
// If no tokens in the pool, only weight contraints will be applied.
require( oldTotalBalance != 0 && newBalances[i].mul(oldTotalBalance) <= newTotalBalance.mul(balances[i]), "penalty is not supported in swapAll now" );
require( oldTotalBalance != 0 && newBalances[i].mul(oldTotalBalance) <= newTotalBalance.mul(balances[i]), "penalty is not supported in swapAll now" );
18,609
29
// mitigates the ERC20 short address attack
modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; }
modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; }
9,711
148
// Function to stop minting new tokens. WARNING: it allows everyone to finish minting. Access controls MUST be defined in derived contracts. /
function finishMinting() external canMint { _finishMinting(); }
function finishMinting() external canMint { _finishMinting(); }
11,580
107
// Sets an interface associated with a name.Setting the address to 0 restores the default behaviour of querying the contract at `addr()` for interface support. node The node to update. interfaceID The EIP 168 interface ID. implementer The address of a contract that implements this interface for this node. /
function setInterface(bytes32 node, bytes4 interfaceID, address implementer) external authorised(node) { interfaces[node][interfaceID] = implementer; emit InterfaceChanged(node, interfaceID, implementer); }
function setInterface(bytes32 node, bytes4 interfaceID, address implementer) external authorised(node) { interfaces[node][interfaceID] = implementer; emit InterfaceChanged(node, interfaceID, implementer); }
18,813
167
// Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-free listings. /
function isApprovedForAll(address _owner, address _operator) public view override returns (bool isOperator)
function isApprovedForAll(address _owner, address _operator) public view override returns (bool isOperator)
12,148
40
// Deposits alTokens into the transmuter // amount the amount of alTokens to stake
function stake(uint256 amount) public noContractAllowed() ensureUserActionDelay() runPhasedDistribution() updateAccount(msg.sender) checkIfNewUser()
function stake(uint256 amount) public noContractAllowed() ensureUserActionDelay() runPhasedDistribution() updateAccount(msg.sender) checkIfNewUser()
47,721
19
// Makes a function callable only when the _owner is not a zero-address.
modifier noneZero(address _owner){ require(_owner != address(0), "Zero address not allowed."); _; }
modifier noneZero(address _owner){ require(_owner != address(0), "Zero address not allowed."); _; }
4,747