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
29
// Collection of functions related to the address type/
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
41,573
51
// EIP-712 Domain separatorreturn Separator /
function getDomainSeparator() public view returns (bytes32) { return keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name)), VERSION_HASH, _getChainId(), address(this) ) ); }
function getDomainSeparator() public view returns (bytes32) { return keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name)), VERSION_HASH, _getChainId(), address(this) ) ); }
32,161
20
// These are related to SOTOX team members
mapping (address => bool) public frozenAccount; mapping (address => uint[3]) public frozenTokens;
mapping (address => bool) public frozenAccount; mapping (address => uint[3]) public frozenTokens;
10,792
75
// Only compound if we're on a new block
uint32 _timeElapsed; unchecked { _timeElapsed = uint32(block.timestamp) - debtTokenData.interestAccumulatorUpdatedAt; }
uint32 _timeElapsed; unchecked { _timeElapsed = uint32(block.timestamp) - debtTokenData.interestAccumulatorUpdatedAt; }
40,848
45
// ERROR CODES /
struct LockedDeposits { uint counter; mapping(uint => uint) index2Date; mapping(uint => uint) date2deposit; }
struct LockedDeposits { uint counter; mapping(uint => uint) index2Date; mapping(uint => uint) date2deposit; }
47,696
21
// Used when any of the resolved stakedCeloGroupVoter.pendingWithdrawalvalues do not match the equivalent record in lockedGold.pendingWithdrawals. /
error InconsistentPendingWithdrawalValues(
error InconsistentPendingWithdrawalValues(
24,966
992
// If the start time is in the past, "fast forward" to start now This avoids discontinuities in the weight curve. Otherwise, if you set the start/end times with only 10% of the period in the future, the weights would immediately jump 90%
uint256 currentTime = block.timestamp; startTime = Math.max(currentTime, startTime); _require(startTime <= endTime, Errors.GRADUAL_UPDATE_TIME_TRAVEL); _startGradualWeightChange(startTime, endTime, _getNormalizedWeights(), endWeights);
uint256 currentTime = block.timestamp; startTime = Math.max(currentTime, startTime); _require(startTime <= endTime, Errors.GRADUAL_UPDATE_TIME_TRAVEL); _startGradualWeightChange(startTime, endTime, _getNormalizedWeights(), endWeights);
30,718
36
// An address for the transfer event where the burned tokens are transferred in a faux Transfer event
address public constant BURN_ADDRESS = 0;
address public constant BURN_ADDRESS = 0;
41,873
23
// User supplies assets into the market and receives cTokens in exchange Assumes interest has already been accrued up to the current block minter The address of the account which is supplying the assets mintAmount The amount of the underlying asset to supply isNative The amount is in native or notreturn (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. /
function mintFresh( address minter, uint256 mintAmount, bool isNative
function mintFresh( address minter, uint256 mintAmount, bool isNative
48,338
31
// views the numeraire value of the current balance of the reserve, in this case token1 instead of calculating with chainlink's "rate" it'll be determined by the existing token ratio. This is in here to prevent LPs from losing out on future oracle price updates
function viewNumeraireBalanceLPRatio( uint256 _baseWeight, uint256 _quoteWeight, address _addr
function viewNumeraireBalanceLPRatio( uint256 _baseWeight, uint256 _quoteWeight, address _addr
31,121
4
// Inserts an item at the beginning of the queue. /
function pushFront(Bytes32Deque storage deque, bytes32 value) internal { int128 frontIndex; unchecked { frontIndex = deque._begin - 1; } deque._data[frontIndex] = value; deque._begin = frontIndex; }
function pushFront(Bytes32Deque storage deque, bytes32 value) internal { int128 frontIndex; unchecked { frontIndex = deque._begin - 1; } deque._data[frontIndex] = value; deque._begin = frontIndex; }
25,308
7
// Assets by ID
mapping(uint256 => Asset) assets;
mapping(uint256 => Asset) assets;
15,195
51
// Transfer balance controlled by magistrate./Magistrate has exclusive rights to withdraw until the end of term./Remaining balance after the next election is rolled over to the next magistrate.
function withdraw(address payable to) public { require(_msgSender() == getMagistrate(), Errors.OnlyMagistrate); // TODO: Someday, would it be fun if this required having a >2 LINK balance to // withdraw? If we wanna be super cute, could automagically buy LINK from // the proceeds before transferring the remaining balance. to.transfer(address(this).balance); }
function withdraw(address payable to) public { require(_msgSender() == getMagistrate(), Errors.OnlyMagistrate); // TODO: Someday, would it be fun if this required having a >2 LINK balance to // withdraw? If we wanna be super cute, could automagically buy LINK from // the proceeds before transferring the remaining balance. to.transfer(address(this).balance); }
18,200
86
// 3
uint256 totalLocked; for(uint idx = 0; idx < timelockList[holder].length ; idx++ ){ totalLocked = totalLocked.add(timelockList[holder][idx]._amount); }
uint256 totalLocked; for(uint idx = 0; idx < timelockList[holder].length ; idx++ ){ totalLocked = totalLocked.add(timelockList[holder][idx]._amount); }
16,108
51
// max transaction is 4% of initialSupply
uint256 public maxTxAmount = initialSupply * 400 / 10000; bool private _swapping;
uint256 public maxTxAmount = initialSupply * 400 / 10000; bool private _swapping;
21,167
2
// write SYN address
syn = _syn;
syn = _syn;
2,162
8
// Sellers sell items and create orders
function Sell(string calldata _sellObject,uint256 _stackAmount,address _allowbuyer) public nonReentrant returns (bool) { require(Address.isContract(_msgSender())==false,"not hunman"); //Administrators can block a certain address for transactions require(!TransactionBan[_msgSender()],"Transaction ban"); require(_stackAmount>=1000000000000000000&&_stackAmount<MAXAmount,"Buy Amount out of range must be more than 1 less than MAXAmount"); //Sellers sell items and create orders. Before that, the user needs to complete the authorization of this transaction contract by eusdt. The recommended authorization value is max (uint256), that is, full authorization require(IERC20(EUSDTAddress).balanceOf(_msgSender())>=_stackAmount,"The number of remaining tokens in the seller is insufficient"); require(IERC20(EUSDTAddress).allowance(_msgSender(),address(this))>=_stackAmount,"Insufficient number of eusdt approvals");// //Payment of pledged eusdt to transaction contract IERC20(EUSDTAddress).safeTransferFrom(_msgSender(),address(this),_stackAmount); //biuld oder TransactionOrder memory oder; oder.identifier=allTransactionOrderIndex; oder.sellObject=_sellObject; oder.stackAmount=_stackAmount; oder.seller=_msgSender(); oder.allowbuyer=_allowbuyer; oder.exemptedovertimelosses=3600;// default 1 hour uint256 userindex=TransactionOrdersLen[_msgSender()]; UserTransactionOrders[_msgSender()][userindex]=oder.identifier; AllTransactionOrders[allTransactionOrderIndex]=oder; allTransactionOrderIndex=allTransactionOrderIndex.add(1); TransactionOrdersLen[_msgSender()]=userindex.add(1); emit TransactionOrderBuildEvent(oder.identifier,oder.seller,oder.sellObject,oder.stackAmount,oder.allowbuyer,oder.exemptedovertimelosses); return true; }
function Sell(string calldata _sellObject,uint256 _stackAmount,address _allowbuyer) public nonReentrant returns (bool) { require(Address.isContract(_msgSender())==false,"not hunman"); //Administrators can block a certain address for transactions require(!TransactionBan[_msgSender()],"Transaction ban"); require(_stackAmount>=1000000000000000000&&_stackAmount<MAXAmount,"Buy Amount out of range must be more than 1 less than MAXAmount"); //Sellers sell items and create orders. Before that, the user needs to complete the authorization of this transaction contract by eusdt. The recommended authorization value is max (uint256), that is, full authorization require(IERC20(EUSDTAddress).balanceOf(_msgSender())>=_stackAmount,"The number of remaining tokens in the seller is insufficient"); require(IERC20(EUSDTAddress).allowance(_msgSender(),address(this))>=_stackAmount,"Insufficient number of eusdt approvals");// //Payment of pledged eusdt to transaction contract IERC20(EUSDTAddress).safeTransferFrom(_msgSender(),address(this),_stackAmount); //biuld oder TransactionOrder memory oder; oder.identifier=allTransactionOrderIndex; oder.sellObject=_sellObject; oder.stackAmount=_stackAmount; oder.seller=_msgSender(); oder.allowbuyer=_allowbuyer; oder.exemptedovertimelosses=3600;// default 1 hour uint256 userindex=TransactionOrdersLen[_msgSender()]; UserTransactionOrders[_msgSender()][userindex]=oder.identifier; AllTransactionOrders[allTransactionOrderIndex]=oder; allTransactionOrderIndex=allTransactionOrderIndex.add(1); TransactionOrdersLen[_msgSender()]=userindex.add(1); emit TransactionOrderBuildEvent(oder.identifier,oder.seller,oder.sellObject,oder.stackAmount,oder.allowbuyer,oder.exemptedovertimelosses); return true; }
2,086
0
// Constructor that gives msg.sender all of existing tokens./
constructor() public ERC20Detailed('USDTTestToken', 'UTT', 18) { _mint(msg.sender, 10000 * (10 ** uint256(decimals()))); }
constructor() public ERC20Detailed('USDTTestToken', 'UTT', 18) { _mint(msg.sender, 10000 * (10 ** uint256(decimals()))); }
8,893
44
// Realize $CARROT earnings and optionally unstake tokens. tokenIds the IDs of the tokens to claim earnings from unstake whether or not to unstake ALL of the tokens listed in tokenIds membership wheather user is membership or not seed account seed sig signature /
function claimRewardsAndUnstake(uint16[] calldata tokenIds, bool unstake, bool membership, uint48 expiration, uint256 seed, bytes memory sig) external whenNotPaused nonReentrant _eosOnly _updateEarnings { require(isValidSignature(msg.sender, membership, expiration, seed, sig), "invalid signature"); uint128 reward; IFoxGameNFT.Kind kind; uint48 time = uint48(block.timestamp); for (uint8 i = 0; i < tokenIds.length; i++) { kind = _getKind(tokenIds[i]); if (kind == IFoxGameNFT.Kind.RABBIT) { reward += _claimRabbitsFromKeep(tokenIds[i], unstake, time, seed); } else if (kind == IFoxGameNFT.Kind.FOX) { reward += _claimFoxFromDen(tokenIds[i], unstake, seed); } else { // HUNTER reward += _claimHunterFromCabin(tokenIds[i], unstake, time); } } if (reward != 0) { foxCarrot.mint(msg.sender, reward); } }
function claimRewardsAndUnstake(uint16[] calldata tokenIds, bool unstake, bool membership, uint48 expiration, uint256 seed, bytes memory sig) external whenNotPaused nonReentrant _eosOnly _updateEarnings { require(isValidSignature(msg.sender, membership, expiration, seed, sig), "invalid signature"); uint128 reward; IFoxGameNFT.Kind kind; uint48 time = uint48(block.timestamp); for (uint8 i = 0; i < tokenIds.length; i++) { kind = _getKind(tokenIds[i]); if (kind == IFoxGameNFT.Kind.RABBIT) { reward += _claimRabbitsFromKeep(tokenIds[i], unstake, time, seed); } else if (kind == IFoxGameNFT.Kind.FOX) { reward += _claimFoxFromDen(tokenIds[i], unstake, seed); } else { // HUNTER reward += _claimHunterFromCabin(tokenIds[i], unstake, time); } } if (reward != 0) { foxCarrot.mint(msg.sender, reward); } }
40,133
92
// Extension of `ERC20Mintable` that adds a cap to the supply of tokens. /
contract ERC20Capped is ERC20Mintable { uint256 private _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ constructor (uint256 cap) public { require(cap > 0, "ERC20Capped: cap is 0"); _cap = cap; } /** * @dev Returns the cap on the token's total supply. */ function cap() public view returns (uint256) { return _cap; } /** * @dev See `ERC20Mintable.mint`. * * Requirements: * * - `value` must not cause the total supply to go over the cap. */ function _mint(address account, uint256 value) internal { require(totalSupply().add(value) <= _cap, "ERC20Capped: cap exceeded"); super._mint(account, value); } }
contract ERC20Capped is ERC20Mintable { uint256 private _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ constructor (uint256 cap) public { require(cap > 0, "ERC20Capped: cap is 0"); _cap = cap; } /** * @dev Returns the cap on the token's total supply. */ function cap() public view returns (uint256) { return _cap; } /** * @dev See `ERC20Mintable.mint`. * * Requirements: * * - `value` must not cause the total supply to go over the cap. */ function _mint(address account, uint256 value) internal { require(totalSupply().add(value) <= _cap, "ERC20Capped: cap exceeded"); super._mint(account, value); } }
38,072
20
// Current cycle deposits counter. Incremented on deposit and decremented on withdrawal.
uint256 public currentCycleDepositsCount;
uint256 public currentCycleDepositsCount;
34,239
37
// Airline has been voted in
flightSuretyData.registerAirline(airline, false); flightSuretyData.resetVoteCounter(airline); emit RegisterAirline(airline);
flightSuretyData.registerAirline(airline, false); flightSuretyData.resetVoteCounter(airline); emit RegisterAirline(airline);
7,789
69
// distribute rewards to each recipient
for ( uint i = 0; i < info.length; i++ ) { if ( info[ i ].rate > 0 ) { ITreasury( treasury ).mintRewards( // mint and send from treasury info[ i ].recipient, nextRewardAt( info[ i ].rate ) ); adjust( i ); // check for adjustment }
for ( uint i = 0; i < info.length; i++ ) { if ( info[ i ].rate > 0 ) { ITreasury( treasury ).mintRewards( // mint and send from treasury info[ i ].recipient, nextRewardAt( info[ i ].rate ) ); adjust( i ); // check for adjustment }
28,519
3
// Claim a Dawn Key quantity The quantity to claim maxKeys The maximum number of keys allocated to this address in the snapshot signature A signature to authenticate the claim /
function claim( uint8 quantity, uint16 maxKeys, bytes memory signature
function claim( uint8 quantity, uint16 maxKeys, bytes memory signature
77,492
2
// The name of this component
string name;
string name;
225
139
// Get the deposit and borrow amount with interest of the user for the handler (internal)userAddr The address of userhandlerID The handler ID return The deposit and borrow amount with interest/
function _getHandlerAmountWithAmount(address payable userAddr, uint256 handlerID) internal view returns (uint256, uint256)
function _getHandlerAmountWithAmount(address payable userAddr, uint256 handlerID) internal view returns (uint256, uint256)
85,131
41
// tokenId ERC721 tokenId of a depositreturn string with metadata JSON containing the NFT's name and description /
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721: nonexistent token"); Deposit storage dep = deposits[tokenId]; return string(abi.encodePacked( '{"name":"Hodl-bonus-pool deposit, tokenId: ', tokenId.toString(), '", "description":"ERC20 asset address: ', (uint(uint160(dep.asset))).toHexString(20), '\\nDeposited amount: ', dep.amount.toString(), ' wei (of token)\\nDeposited at: ', uint(dep.time).toString(), ' seconds unix epoch\\nInitial penalty percent: ', uint(dep.initialPenaltyPercent).toString(), '%\\nCommitment period: ', uint(dep.commitPeriod).toString(), ' seconds"}' )); }
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721: nonexistent token"); Deposit storage dep = deposits[tokenId]; return string(abi.encodePacked( '{"name":"Hodl-bonus-pool deposit, tokenId: ', tokenId.toString(), '", "description":"ERC20 asset address: ', (uint(uint160(dep.asset))).toHexString(20), '\\nDeposited amount: ', dep.amount.toString(), ' wei (of token)\\nDeposited at: ', uint(dep.time).toString(), ' seconds unix epoch\\nInitial penalty percent: ', uint(dep.initialPenaltyPercent).toString(), '%\\nCommitment period: ', uint(dep.commitPeriod).toString(), ' seconds"}' )); }
24,330
9
// Tcrit ≥ 0 - the time during which the utilization exceeds the critical value
int256 Tcrit;
int256 Tcrit;
24,636
8
// received pot swap deposit
event onPotSwapDeposit ( uint256 roundID, uint256 amountAddedToPot );
event onPotSwapDeposit ( uint256 roundID, uint256 amountAddedToPot );
51,520
73
// {See ICreatorCore-royaltyInfo}. /
function royaltyInfo(uint256 tokenId, uint256 value) external view virtual override returns (address, uint256) { return _getRoyaltyInfo(tokenId, value); }
function royaltyInfo(uint256 tokenId, uint256 value) external view virtual override returns (address, uint256) { return _getRoyaltyInfo(tokenId, value); }
27,132
109
// Returns the cost in XP for a user to rank up. user The user's address.return The cost in XP for the user to rank up. /
function getRankUpCostXP(address user) public view returns (uint256) { IGuildID guildID = IGuildID(_contracts.guildID); return _rankUpBasePriceXP * (guildID.getRank(guildID.getID(user)) + 1); }
function getRankUpCostXP(address user) public view returns (uint256) { IGuildID guildID = IGuildID(_contracts.guildID); return _rankUpBasePriceXP * (guildID.getRank(guildID.getID(user)) + 1); }
33,866
47
// ========== RESTRICTED FUNCTIONS (SIGNATURE REQUIRED) ========== //Claim the asset of a swap request on source chain after YPool worker `closeSwap` on target chain, by providing signatures of validators/ Claiming MUST be performed on source chain/Signatures from validators are first sent to SwapValidator contract on Settlement chain to validate a swap request. Then the signatures can be reused here to approve the claim/_swapId Swap id of the swap request/signatures Signatures of validators
function claim(uint256 _swapId, bytes[] memory signatures) external whenNotPaused { require(_swapId < swapId, "ERR_INVALID_SWAPID"); require(swapRequests[_swapId].status != RequestStatus.Closed, "ERR_ALREADY_CLOSED"); swapRequests[_swapId].status = RequestStatus.Closed; bytes32 sigId = keccak256(abi.encodePacked(supervisor.VALIDATE_SWAP_IDENTIFIER(), address(swapValidatorXYChain), chainId, _swapId)); bytes32 sigIdHash = sigId.toEthSignedMessageHash(); supervisor.checkSignatures(sigIdHash, signatures); SwapRequest memory request = swapRequests[_swapId]; IYPoolVault yPoolVault = IYPoolVault(YPoolVaults[address(request.YPoolToken)]); uint256 value = (address(request.YPoolToken) == ETHER_ADDRESS) ? request.YPoolTokenAmount : 0; if (address(request.YPoolToken) != ETHER_ADDRESS) { request.YPoolToken.safeApprove(address(yPoolVault), request.YPoolTokenAmount); } yPoolVault.receiveAssetFromSwapper{value: value}(request.YPoolToken, request.YPoolTokenAmount, request.xyFee, request.gasFee); emit SwapCompleted(CompleteSwapType.Claimed, request); }
function claim(uint256 _swapId, bytes[] memory signatures) external whenNotPaused { require(_swapId < swapId, "ERR_INVALID_SWAPID"); require(swapRequests[_swapId].status != RequestStatus.Closed, "ERR_ALREADY_CLOSED"); swapRequests[_swapId].status = RequestStatus.Closed; bytes32 sigId = keccak256(abi.encodePacked(supervisor.VALIDATE_SWAP_IDENTIFIER(), address(swapValidatorXYChain), chainId, _swapId)); bytes32 sigIdHash = sigId.toEthSignedMessageHash(); supervisor.checkSignatures(sigIdHash, signatures); SwapRequest memory request = swapRequests[_swapId]; IYPoolVault yPoolVault = IYPoolVault(YPoolVaults[address(request.YPoolToken)]); uint256 value = (address(request.YPoolToken) == ETHER_ADDRESS) ? request.YPoolTokenAmount : 0; if (address(request.YPoolToken) != ETHER_ADDRESS) { request.YPoolToken.safeApprove(address(yPoolVault), request.YPoolTokenAmount); } yPoolVault.receiveAssetFromSwapper{value: value}(request.YPoolToken, request.YPoolTokenAmount, request.xyFee, request.gasFee); emit SwapCompleted(CompleteSwapType.Claimed, request); }
35,478
42
// MODIFIERS /
45,035
4
// Solidity in-memory arrays can't be increased in size, but can be decreased in size by writing to the length. Since we can't know the number of RLP items without looping over the entire input, we'd have to loop twice to accurately size this array. It's easier to simply set a reasonable maximum list length and decrease the size before we finish.
RLPItem[] memory out = new RLPItem[](MAX_LIST_LENGTH); uint256 itemCount = 0; uint256 offset = listOffset; while (offset < _in.length) { require( itemCount < MAX_LIST_LENGTH, 'Provided RLP list exceeds max list length.' );
RLPItem[] memory out = new RLPItem[](MAX_LIST_LENGTH); uint256 itemCount = 0; uint256 offset = listOffset; while (offset < _in.length) { require( itemCount < MAX_LIST_LENGTH, 'Provided RLP list exceeds max list length.' );
31,678
18
// function to fetchMarketItmes - minting, buying and selling return the number of unsold items
function fetchMarketTokens() public view returns(MarketToken[] memory) { uint itemCount = _tokenIds.current(); uint unsoldItemCount = _tokenIds.current() - _tokensSold.current(); uint currentIndex = 0; // looping over the number of items created (if number has not been sold pupulte the array) MarketToken[] memory items = new MarketToken[](unsoldItemCount); for(uint i = 0; i < itemCount; i++) { if(idToMarketToken[i+1].owner == address(0)) { uint currentId = i + 1; MarketToken storage currentItem = idToMarketToken[currentId]; items[currentIndex] = currentItem; currentIndex += 1; } } return items; }
function fetchMarketTokens() public view returns(MarketToken[] memory) { uint itemCount = _tokenIds.current(); uint unsoldItemCount = _tokenIds.current() - _tokensSold.current(); uint currentIndex = 0; // looping over the number of items created (if number has not been sold pupulte the array) MarketToken[] memory items = new MarketToken[](unsoldItemCount); for(uint i = 0; i < itemCount; i++) { if(idToMarketToken[i+1].owner == address(0)) { uint currentId = i + 1; MarketToken storage currentItem = idToMarketToken[currentId]; items[currentIndex] = currentItem; currentIndex += 1; } } return items; }
9,533
75
// Set contract creator as initial owner /
constructor() public { owner = msg.sender; pendingOwner = address(0); }
constructor() public { owner = msg.sender; pendingOwner = address(0); }
36,760
29
// Block number at which the challenge period ends, in case it has been initiated.
uint32 settle_block_number;
uint32 settle_block_number;
51,854
70
// Group-buy contract for Token ICO/Joe Wasson/Allows for group purchase of the Token ICO. This is done/ in two phases:/ a) contributions initiate a purchase on demand./ b) tokens are collected when they are unfrozen
contract TokenBuy is Pausable, Claimable, TokenDestructible, DSMath { using SafeERC20 for ERC20Basic; /// @notice Token ICO contract ACOTokenCrowdsale public crowdsaleContract; /// @notice Token contract ERC20Basic public tokenContract; /// @notice Map of contributors and their token balances mapping(address => uint) public balances; /// @notice List of contributors to the sale address[] public contributors; /// @notice Total amount contributed to the sale uint public totalContributions; /// @notice Total number of tokens purchased uint public totalTokensPurchased; /// @notice Emitted whenever a contribution is made event Purchase(address indexed sender, uint ethAmount, uint tokensPurchased); /// @notice Emitted whenever tokens are collected fromthe contract event Collection(address indexed recipient, uint amount); /// @notice Time when locked funds in the contract can be retrieved. uint constant unlockTime = 1543622400; // 2018-12-01 00:00:00 GMT /// @notice Guards against executing the function if the sale /// is not running. modifier whenSaleRunning() { require(!crowdsaleContract.hasEnded()); _; } /// @param crowdsale the Crowdsale contract (or a wrapper around it) /// @param token the token contract constructor(ACOTokenCrowdsale crowdsale, ERC20Basic token) public { require(crowdsale != address(0x0)); require(token != address(0x0)); crowdsaleContract = crowdsale; tokenContract = token; } /// @notice returns the number of contributors in the list of contributors /// @return count of contributors /// @dev As the `collectAll` function is called the contributor array is cleaned up /// consequently this method only returns the remaining contributor count. function contributorCount() public view returns (uint) { return contributors.length; } /// @dev Dispatches between buying and collecting function() public payable { if (msg.value == 0) { collectFor(msg.sender); } else { buy(); } } /// @notice Executes a purchase. function buy() whenNotPaused whenSaleRunning private { address buyer = msg.sender; totalContributions += msg.value; uint tokensPurchased = purchaseTokens(); totalTokensPurchased = add(totalTokensPurchased, tokensPurchased); uint previousBalance = balances[buyer]; balances[buyer] = add(previousBalance, tokensPurchased); // new contributor if (previousBalance == 0) { contributors.push(buyer); } emit Purchase(buyer, msg.value, tokensPurchased); } function purchaseTokens() private returns (uint tokensPurchased) { address me = address(this); uint previousBalance = tokenContract.balanceOf(me); crowdsaleContract.buyTokens.value(msg.value)(me); uint newBalance = tokenContract.balanceOf(me); require(newBalance > previousBalance); // Fail on underflow or purchase of 0 return newBalance - previousBalance; } /// @notice Allows users to collect purchased tokens after the sale. /// @param recipient the address to collect tokens for /// @dev Here we don't transfer zero tokens but this is an arbitrary decision. function collectFor(address recipient) private { uint tokensOwned = balances[recipient]; if (tokensOwned == 0) return; delete balances[recipient]; tokenContract.safeTransfer(recipient, tokensOwned); emit Collection(recipient, tokensOwned); } /// @notice Collects the balances for members of the purchase /// @param max the maximum number of members to process (for gas purposes) function collectAll(uint8 max) public returns (uint8 collected) { max = uint8(min(max, contributors.length)); require(max > 0, "can't collect for zero users"); uint index = contributors.length - 1; for(uint offset = 0; offset < max; ++offset) { address recipient = contributors[index - offset]; if (balances[recipient] > 0) { collected++; collectFor(recipient); } } contributors.length -= offset; } /// @notice Shuts down the contract function destroy(address[] tokens) onlyOwner public { require(now > unlockTime || (contributorCount() == 0 && paused)); super.destroy(tokens); } }
contract TokenBuy is Pausable, Claimable, TokenDestructible, DSMath { using SafeERC20 for ERC20Basic; /// @notice Token ICO contract ACOTokenCrowdsale public crowdsaleContract; /// @notice Token contract ERC20Basic public tokenContract; /// @notice Map of contributors and their token balances mapping(address => uint) public balances; /// @notice List of contributors to the sale address[] public contributors; /// @notice Total amount contributed to the sale uint public totalContributions; /// @notice Total number of tokens purchased uint public totalTokensPurchased; /// @notice Emitted whenever a contribution is made event Purchase(address indexed sender, uint ethAmount, uint tokensPurchased); /// @notice Emitted whenever tokens are collected fromthe contract event Collection(address indexed recipient, uint amount); /// @notice Time when locked funds in the contract can be retrieved. uint constant unlockTime = 1543622400; // 2018-12-01 00:00:00 GMT /// @notice Guards against executing the function if the sale /// is not running. modifier whenSaleRunning() { require(!crowdsaleContract.hasEnded()); _; } /// @param crowdsale the Crowdsale contract (or a wrapper around it) /// @param token the token contract constructor(ACOTokenCrowdsale crowdsale, ERC20Basic token) public { require(crowdsale != address(0x0)); require(token != address(0x0)); crowdsaleContract = crowdsale; tokenContract = token; } /// @notice returns the number of contributors in the list of contributors /// @return count of contributors /// @dev As the `collectAll` function is called the contributor array is cleaned up /// consequently this method only returns the remaining contributor count. function contributorCount() public view returns (uint) { return contributors.length; } /// @dev Dispatches between buying and collecting function() public payable { if (msg.value == 0) { collectFor(msg.sender); } else { buy(); } } /// @notice Executes a purchase. function buy() whenNotPaused whenSaleRunning private { address buyer = msg.sender; totalContributions += msg.value; uint tokensPurchased = purchaseTokens(); totalTokensPurchased = add(totalTokensPurchased, tokensPurchased); uint previousBalance = balances[buyer]; balances[buyer] = add(previousBalance, tokensPurchased); // new contributor if (previousBalance == 0) { contributors.push(buyer); } emit Purchase(buyer, msg.value, tokensPurchased); } function purchaseTokens() private returns (uint tokensPurchased) { address me = address(this); uint previousBalance = tokenContract.balanceOf(me); crowdsaleContract.buyTokens.value(msg.value)(me); uint newBalance = tokenContract.balanceOf(me); require(newBalance > previousBalance); // Fail on underflow or purchase of 0 return newBalance - previousBalance; } /// @notice Allows users to collect purchased tokens after the sale. /// @param recipient the address to collect tokens for /// @dev Here we don't transfer zero tokens but this is an arbitrary decision. function collectFor(address recipient) private { uint tokensOwned = balances[recipient]; if (tokensOwned == 0) return; delete balances[recipient]; tokenContract.safeTransfer(recipient, tokensOwned); emit Collection(recipient, tokensOwned); } /// @notice Collects the balances for members of the purchase /// @param max the maximum number of members to process (for gas purposes) function collectAll(uint8 max) public returns (uint8 collected) { max = uint8(min(max, contributors.length)); require(max > 0, "can't collect for zero users"); uint index = contributors.length - 1; for(uint offset = 0; offset < max; ++offset) { address recipient = contributors[index - offset]; if (balances[recipient] > 0) { collected++; collectFor(recipient); } } contributors.length -= offset; } /// @notice Shuts down the contract function destroy(address[] tokens) onlyOwner public { require(now > unlockTime || (contributorCount() == 0 && paused)); super.destroy(tokens); } }
26,767
61
// save in returned value the amount of weth receive to use off-chain
_balances[i] = _res[_res.length - 1];
_balances[i] = _res[_res.length - 1];
5,288
0
// The mode that the App is currently in from POV of the blockchain
enum AppStatus { ON, DISPUTE, OFF }
enum AppStatus { ON, DISPUTE, OFF }
33,302
94
// `(_prevId, _nextId)` is a valid insert position if they are adjacent nodes and `_key` falls between the two nodes' keys
return self.nodes[_prevId].nextId == _nextId && self.nodes[_prevId].key >= _key && _key >= self.nodes[_nextId].key;
return self.nodes[_prevId].nextId == _nextId && self.nodes[_prevId].key >= _key && _key >= self.nodes[_nextId].key;
45,732
79
// Total DVD that have been burned./These DVD are still in circulation therefore they/ are still considered on the bonding curve formula./ return Total burned DVD in wei.
function dvdBurnedAmount() public view returns (uint256) { return IERC20(dvd).balanceOf(BURN_ADDRESS); }
function dvdBurnedAmount() public view returns (uint256) { return IERC20(dvd).balanceOf(BURN_ADDRESS); }
10,224
184
// Setter for refill price /
function setStnRefillPrice(uint _stnRefillPrice) external onlyOwner { stnRefillPrice = _stnRefillPrice; }
function setStnRefillPrice(uint _stnRefillPrice) external onlyOwner { stnRefillPrice = _stnRefillPrice; }
73,447
94
// Validate inputs
require(weiAmount != 0, "BeardGangLandNFTICO: ETH sent 0"); require(_beneficiary != address(0), "BeardGangLandNFTICO: beneficiary zero address");
require(weiAmount != 0, "BeardGangLandNFTICO: ETH sent 0"); require(_beneficiary != address(0), "BeardGangLandNFTICO: beneficiary zero address");
40,897
320
// function to dynamically change supply
function changeSupply(uint256 _supply) external onlyOwner { maxSupply = _supply; }
function changeSupply(uint256 _supply) external onlyOwner { maxSupply = _supply; }
25,778
38
// Timestamp of the moment the swap was created. Always set to `now` on creation This field is also used to check for struct existence by comparing it against 0
uint startTimestamp;
uint startTimestamp;
45,569
20
// Mints liquidity tokens./The input tokens must've already been sent to the pool./data ABI-encoded params that the pool requires./ return liquidity The amount of liquidity tokens that were minted for the user.
function mint(bytes calldata data) external returns (uint256 liquidity);
function mint(bytes calldata data) external returns (uint256 liquidity);
30,966
22
// submit re-rollup batch indexbatchIndex need re-rollup batch index/
function submitReRollUpInfo( uint256 batchIndex
function submitReRollUpInfo( uint256 batchIndex
29,558
7
// Emit when the token ticker expiry is changed
event ChangeExpiryLimit(uint256 _oldExpiry, uint256 _newExpiry);
event ChangeExpiryLimit(uint256 _oldExpiry, uint256 _newExpiry);
50,559
102
// Internal function to stake all outstanding LP tokens to the given position ID.
function _addShare(uint256 id) internal { uint256 balance = lpToken.balanceOf(address(this)); if (balance > 0) { uint256 share = balanceToShare(balance); masterChef.deposit(pid, balance); shares[id] = shares[id].add(share); totalShare = totalShare.add(share); emit AddShare(id, share); } }
function _addShare(uint256 id) internal { uint256 balance = lpToken.balanceOf(address(this)); if (balance > 0) { uint256 share = balanceToShare(balance); masterChef.deposit(pid, balance); shares[id] = shares[id].add(share); totalShare = totalShare.add(share); emit AddShare(id, share); } }
20,049
93
// Change partner address _nftAddress Token maket fee address _tokenCreaterAddress Partner addressOnly partner can change their share address /
function changeTokenCreaterAddress( address _nftAddress,
function changeTokenCreaterAddress( address _nftAddress,
22,373
3
// Certify document creation with hash and timestampIt registers in the blockchain the proof-of-existence of an external document_documentHash - Hash of the document (it should have 32 bytes) return id - returns certified document id/
function certifyDocumentCreation(bytes32 _documentHash, string memory _timestamp)
function certifyDocumentCreation(bytes32 _documentHash, string memory _timestamp)
43,987
8
// save contributor address
t.contributions[_sender] = _amount; t.index[_sender] = t.senders.length;
t.contributions[_sender] = _amount; t.index[_sender] = t.senders.length;
23,891
35
// Backwards compatibility
function mintedBalance() public view returns (int256) { return amo_minter.frax_mint_balances(address(this)); }
function mintedBalance() public view returns (int256) { return amo_minter.frax_mint_balances(address(this)); }
10,536
15
// can only call functions that have no parameters
function upgradePolicyBooksAndCall( address policyBookImpl, uint256 offset, uint256 limit, string calldata functionSignature
function upgradePolicyBooksAndCall( address policyBookImpl, uint256 offset, uint256 limit, string calldata functionSignature
27,182
85
// Ensure the message validity.
require(validateOrderHash(hash, msg.sender, v, r, s));
require(validateOrderHash(hash, msg.sender, v, r, s));
34,401
121
// Should return whether the signature provided is valid for the provided data _data Arbitrary length data signed on the behalf of address(this) _signature Signature byte array associated with _data MUST return the bytes4 magic value 0x20c13b0b when function passes.MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)MUST allow external calls /
function isValidSignature(bytes memory _data, bytes memory _signature) public view virtual returns (bytes4);
function isValidSignature(bytes memory _data, bytes memory _signature) public view virtual returns (bytes4);
8,037
57
// Both - (1) offers to direct listings, and (2) bids to auctions - share the same structure.
Offer memory newOffer = Offer({ listingId: _listingId, offeror: _msgSender(), quantityWanted: _quantityWanted, currency: _currency, pricePerToken: _pricePerToken, expirationTimestamp: _expirationTimestamp });
Offer memory newOffer = Offer({ listingId: _listingId, offeror: _msgSender(), quantityWanted: _quantityWanted, currency: _currency, pricePerToken: _pricePerToken, expirationTimestamp: _expirationTimestamp });
3,498
44
// LAYA Token. /
contract LAYA is PausableToken { string public name = "LAYA Token"; string public symbol = "LAYA"; uint public decimals = 8; string public version = "1.0"; event Burn(address indexed from, uint256 value); function LAYA() public { totalSupply_ = 100000000000 * 10 ** 8; balances[owner] = totalSupply_; } function burn(uint256 _value) onlyOwner public returns (bool success) { require(balances[msg.sender] >= _value); // Check if the sender has enough require(_value > 0); balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender totalSupply_ = totalSupply_.sub(_value); // Updates totalSupply Burn(msg.sender, _value); return true; } function () public { revert(); } }
contract LAYA is PausableToken { string public name = "LAYA Token"; string public symbol = "LAYA"; uint public decimals = 8; string public version = "1.0"; event Burn(address indexed from, uint256 value); function LAYA() public { totalSupply_ = 100000000000 * 10 ** 8; balances[owner] = totalSupply_; } function burn(uint256 _value) onlyOwner public returns (bool success) { require(balances[msg.sender] >= _value); // Check if the sender has enough require(_value > 0); balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender totalSupply_ = totalSupply_.sub(_value); // Updates totalSupply Burn(msg.sender, _value); return true; } function () public { revert(); } }
65,150
102
// or 0-9
(_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" );
(_temp[i] > 0x2f && _temp[i] < 0x3a), "string contains invalid characters" );
3,992
64
// Storage for each lots price
struct LotPrice { uint256 pricePerEdition; // The cost per token uint256 maxBatchBuy; // The max amount of tokens per TX uint256 tokenID; uint256 startTime; uint256 endTime; bool biddable; bool useMaxStock; uint256 maxStock; uint256 tokensMinted; }
struct LotPrice { uint256 pricePerEdition; // The cost per token uint256 maxBatchBuy; // The max amount of tokens per TX uint256 tokenID; uint256 startTime; uint256 endTime; bool biddable; bool useMaxStock; uint256 maxStock; uint256 tokensMinted; }
41,326
9
// A mapping for executed requests
mapping(uint256 => bool) public executedRequests;
mapping(uint256 => bool) public executedRequests;
2,312
69
// Deploys and returns the address of a clone that mimics the behaviour of `master`. This function uses the create opcode, which should never revert. /
function clone(address master) internal returns (address instance) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, master)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); }
function clone(address master) internal returns (address instance) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, master)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); }
4,948
13
// Creates `_amount` PWDR token to `_to`.Can only be called by the LGE, Slopes, and Avalanche contractswhen epoch and max supply numbers allow
function mint(address _to, uint256 _amount) external override Accumulation MaxSupplyNotReached OnlyAuthorized
function mint(address _to, uint256 _amount) external override Accumulation MaxSupplyNotReached OnlyAuthorized
20,860
63
// 管理员取出BHC
function fetchBHC(address _to, uint256 _value) public onlyOwner returns (bool success2) { // 不能是0地址 require(_to != address(0)); (bool success, ) = BHCAddress.call( abi.encodeWithSelector(SELECTOR, _to, _value) ); if(!success) { revert("transfer fail"); } success2 = true; }
function fetchBHC(address _to, uint256 _value) public onlyOwner returns (bool success2) { // 不能是0地址 require(_to != address(0)); (bool success, ) = BHCAddress.call( abi.encodeWithSelector(SELECTOR, _to, _value) ); if(!success) { revert("transfer fail"); } success2 = true; }
9,706
47
// should run end round
if ( minigames[miniGameId].endTime < now ) { endMiniGame(); }
if ( minigames[miniGameId].endTime < now ) { endMiniGame(); }
32,627
0
// Deploy a Pool./ Make sure that the fyToken follows ERC20 standards with regards to name, symbol and decimals
constructor(IERC20 base_, IFYToken fyToken_, int128 ts_, int128 g1_, int128 g2_) ERC20Permit( string(abi.encodePacked(IERC20Metadata(address(fyToken_)).name(), " LP")), string(abi.encodePacked(IERC20Metadata(address(fyToken_)).symbol(), "LP")), IERC20Metadata(address(fyToken_)).decimals() )
constructor(IERC20 base_, IFYToken fyToken_, int128 ts_, int128 g1_, int128 g2_) ERC20Permit( string(abi.encodePacked(IERC20Metadata(address(fyToken_)).name(), " LP")), string(abi.encodePacked(IERC20Metadata(address(fyToken_)).symbol(), "LP")), IERC20Metadata(address(fyToken_)).decimals() )
47,743
18
// merge it into the first draw, and update the second draw index to this one
uint256 firstAmount = self.sortitionSumTrees.stakeOf(bytes32(firstDrawIndex), userId); uint256 secondAmount = self.sortitionSumTrees.stakeOf(bytes32(secondDrawIndex), userId); drawSet(self, firstDrawIndex, firstAmount.add(secondAmount), _addr); drawSet(self, secondDrawIndex, 0, _addr); self.usersSecondDrawIndex[_addr] = openDrawIndex;
uint256 firstAmount = self.sortitionSumTrees.stakeOf(bytes32(firstDrawIndex), userId); uint256 secondAmount = self.sortitionSumTrees.stakeOf(bytes32(secondDrawIndex), userId); drawSet(self, firstDrawIndex, firstAmount.add(secondAmount), _addr); drawSet(self, secondDrawIndex, 0, _addr); self.usersSecondDrawIndex[_addr] = openDrawIndex;
17,210
3
// Return the last day on which the Oracle is updated /
function getLastIndexedDay() external view returns (uint32);
function getLastIndexedDay() external view returns (uint32);
9,920
115
// Get Uint value from InstaMemory Contract. /
function getUint(uint getId, uint val) internal returns (uint returnVal) { returnVal = getId == 0 ? val : instaMemory.getUint(getId);
function getUint(uint getId, uint val) internal returns (uint returnVal) { returnVal = getId == 0 ? val : instaMemory.getUint(getId);
11,180
136
// Write the character to the pointer. 48 is the ASCII index of '0'.
mstore8(ptr, add(48, mod(temp, 10))) temp := div(temp, 10)
mstore8(ptr, add(48, mod(temp, 10))) temp := div(temp, 10)
12,979
234
// Helper: Returns boolean if we are before the freeze period. /
function isBeforeFreeze(ExecutionWindow storage self) internal view returns (bool)
function isBeforeFreeze(ExecutionWindow storage self) internal view returns (bool)
53,361
300
// Validates seize and reverts on rejection. May emit logs. cTokenCollateral Asset which was used as collateral and will be seized cTokenBorrowed Asset which was borrowed by the borrower liquidator The address repaying the borrow and seizing the collateral borrower The address of the borrower seizeTokens The number of collateral tokens to seize /
function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower,
function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower,
7,503
4
// Function to transfer tokens to the Treasury. Only BIG_TIMELOCK_ADMIN can call it. bucket The bucket from which to transfer pTokens amount The amount of pTokens to transfer /
function transferToTreasury(address bucket, uint256 amount) external;
function transferToTreasury(address bucket, uint256 amount) external;
30,334
353
// Whether or not the admin has admin rights /
bool public adminHasRights = true;
bool public adminHasRights = true;
61,104
1
// The maximum yoda token supply
uint256 public constant MAX_SUPPLY = 2022;
uint256 public constant MAX_SUPPLY = 2022;
13,884
41
// now resume the token sale
tokenSaleIsPaused = false; emit SaleResumed("token sale has now resumed", now);
tokenSaleIsPaused = false; emit SaleResumed("token sale has now resumed", now);
41,960
32
// quart coefficient is sqrt(sqrt(4.4))
if(fullQuarts != 0) { price = price * 14483154**fullQuarts; price = price / 10**(7 * fullQuarts); }
if(fullQuarts != 0) { price = price * 14483154**fullQuarts; price = price / 10**(7 * fullQuarts); }
36,714
25
// this event shows the other signer and the operation hash that they signed specific batch transfer events are emitted in Batcher
event BatchTransacted( address msgSender, // Address of the sender of the message initiating the transaction address otherSigner, // Address of the signer (second signature) used to initiate the transaction bytes32 operation // Operation hash (see Data Formats) );
event BatchTransacted( address msgSender, // Address of the sender of the message initiating the transaction address otherSigner, // Address of the signer (second signature) used to initiate the transaction bytes32 operation // Operation hash (see Data Formats) );
14,202
60
// Validates borrow and reverts on rejection. May emit logs. slToken Asset whose underlying is being borrowed borrower The address borrowing the underlying borrowAmount The amount of the underlying asset requested to borrow /
function borrowVerify(address slToken, address borrower, uint borrowAmount) external { // Shh - currently unused slToken; borrower; borrowAmount; // Shh - we don't ever want this hook to be marked pure if (false) { maxAssets = maxAssets; } }
function borrowVerify(address slToken, address borrower, uint borrowAmount) external { // Shh - currently unused slToken; borrower; borrowAmount; // Shh - we don't ever want this hook to be marked pure if (false) { maxAssets = maxAssets; } }
7,513
205
// Hack to get things to work automatically on OpenSea.Use safeTransferFrom so the frontend doesn't have to worry about different method names. /
function safeTransferFrom( address /* _from */, address _to, uint256 _optionId, uint256 _amount, bytes calldata _data
function safeTransferFrom( address /* _from */, address _to, uint256 _optionId, uint256 _amount, bytes calldata _data
12,434
59
// Max wallet check excluding pair and router
if (!isSell && !_isFree[recipient]){ require((_balances[recipient] + amount) < _maxWallet, "Max wallet has been triggered"); }
if (!isSell && !_isFree[recipient]){ require((_balances[recipient] + amount) < _maxWallet, "Max wallet has been triggered"); }
58,530
30
// Replacement for Solidity's `transfer`: sends `amount` wei to`recipient`, forwarding all available gas and reverting on errors. of certain opcodes, possibly making contracts go over the 2300 gas limitimposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation. * * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); }
* `transfer`. {sendValue} removes this limitation. * * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); }
25,606
16
// Maintain a memory counter for the current write location in the temp bytes array by adding the 32 bytes for the array length to the starting location.
let mc := add(tempBytes, 0x20)
let mc := add(tempBytes, 0x20)
24,211
18
// Checks pair for sweep amount available
function sweepAmountAvailable(IUniswapV2Pair pair) public view returns (uint amountAvailable) { require(pairRegistered[address(pair)], "!pairRegistered[pair]"); bool xethIsToken0 = false; IERC20 token; if(pair.token0() == address(_xeth)) { xethIsToken0 = true; token = IERC20(pair.token1()); } else { require(pair.token1() == address(_xeth), "!pair.tokenX==address(_xeth)"); token = IERC20(pair.token0()); } (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = pair.getReserves(); uint burnedLP = pair.balanceOf(address(0)); uint totalLP = pair.totalSupply(); uint reserveLockedXeth = uint(xethIsToken0 ? reserve0 : reserve1).mul(burnedLP).div(totalLP); uint reserveLockedToken = uint(xethIsToken0 ? reserve1 : reserve0).mul(burnedLP).div(totalLP); uint burnedXeth; if(reserveLockedToken == token.totalSupply()) { burnedXeth = reserveLockedXeth; }else{ burnedXeth = reserveLockedXeth.sub( UniswapV2Library.getAmountOut( //Circulating supply, max that could ever be sold (amountIn) token.totalSupply().sub(reserveLockedToken), //Burned token in Uniswap reserves (reserveIn) reserveLockedToken, //Burned uEth in Uniswap reserves (reserveOut) reserveLockedXeth ) ); } return burnedXeth.sub(pairSwept[address(pair)]); }
function sweepAmountAvailable(IUniswapV2Pair pair) public view returns (uint amountAvailable) { require(pairRegistered[address(pair)], "!pairRegistered[pair]"); bool xethIsToken0 = false; IERC20 token; if(pair.token0() == address(_xeth)) { xethIsToken0 = true; token = IERC20(pair.token1()); } else { require(pair.token1() == address(_xeth), "!pair.tokenX==address(_xeth)"); token = IERC20(pair.token0()); } (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = pair.getReserves(); uint burnedLP = pair.balanceOf(address(0)); uint totalLP = pair.totalSupply(); uint reserveLockedXeth = uint(xethIsToken0 ? reserve0 : reserve1).mul(burnedLP).div(totalLP); uint reserveLockedToken = uint(xethIsToken0 ? reserve1 : reserve0).mul(burnedLP).div(totalLP); uint burnedXeth; if(reserveLockedToken == token.totalSupply()) { burnedXeth = reserveLockedXeth; }else{ burnedXeth = reserveLockedXeth.sub( UniswapV2Library.getAmountOut( //Circulating supply, max that could ever be sold (amountIn) token.totalSupply().sub(reserveLockedToken), //Burned token in Uniswap reserves (reserveIn) reserveLockedToken, //Burned uEth in Uniswap reserves (reserveOut) reserveLockedXeth ) ); } return burnedXeth.sub(pairSwept[address(pair)]); }
26,367
8
// bonus owner can transfer their bonus wei to any investor account before bonus period ended
function fillInvestorAccountWithBonus(address accountAddress) onlyBonusOwner { if(investorsAccounts[accountAddress]==-1 || investorsAccounts[accountAddress]>0) { var bonusValue = ownedBonus[msg.sender]; ownedBonus[msg.sender] = 0; if(investorsAccounts[accountAddress]==-1) investorsAccounts[accountAddress]==0; investorsAccounts[accountAddress] += int(bonusValue); AccountFilledWithBonus(accountAddress, bonusValue, investorsAccounts[accountAddress]); accountAddress.transfer(bonusValue); } }
function fillInvestorAccountWithBonus(address accountAddress) onlyBonusOwner { if(investorsAccounts[accountAddress]==-1 || investorsAccounts[accountAddress]>0) { var bonusValue = ownedBonus[msg.sender]; ownedBonus[msg.sender] = 0; if(investorsAccounts[accountAddress]==-1) investorsAccounts[accountAddress]==0; investorsAccounts[accountAddress] += int(bonusValue); AccountFilledWithBonus(accountAddress, bonusValue, investorsAccounts[accountAddress]); accountAddress.transfer(bonusValue); } }
29,297
7
// check if some coupons outdatedhelper function
function updateCoupon(uint ID, uint _date) public{ for(uint i = 0; i < Members[ID].CouponsCount; i++){ if(Members[ID].Coupons[i].endDate < _date){ delete Members[ID].Coupons[i]; for(uint j = i+1; j <Members[ID].CouponsCount; j++){ Members[ID].Coupons[j-1] = Members[ID].Coupons[j]; } Members[ID].CouponsCount--; } } }
function updateCoupon(uint ID, uint _date) public{ for(uint i = 0; i < Members[ID].CouponsCount; i++){ if(Members[ID].Coupons[i].endDate < _date){ delete Members[ID].Coupons[i]; for(uint j = i+1; j <Members[ID].CouponsCount; j++){ Members[ID].Coupons[j-1] = Members[ID].Coupons[j]; } Members[ID].CouponsCount--; } } }
22,228
39
// Get the minimum and maximum amount of stable token than can be involved in the exchange. This reverts if exchange limits for the stable token have not been set.
(uint256 minExchangeAmount, uint256 maxExchangeAmount) = getStableTokenExchangeLimits( stableTokenRegistryId );
(uint256 minExchangeAmount, uint256 maxExchangeAmount) = getStableTokenExchangeLimits( stableTokenRegistryId );
37,849
139
// The function allow Wallet to Mint Tokens payied by bank transfer and credit card /
function addAllowedWallet(address _wallet, bool isAllowed) public { bool public mintingIsLive = true; bool public inRewardsPaused = true; bool public sendAndLiquifyEnabled = false; address public deadWallet = address(0x000000000000000000000000000000000000dEaD); mapping(address => bool) private _isExcludedFromMaxTx; bool public tradeIsOpen = false; allowedWallet[_wallet] = isAllowed; }
function addAllowedWallet(address _wallet, bool isAllowed) public { bool public mintingIsLive = true; bool public inRewardsPaused = true; bool public sendAndLiquifyEnabled = false; address public deadWallet = address(0x000000000000000000000000000000000000dEaD); mapping(address => bool) private _isExcludedFromMaxTx; bool public tradeIsOpen = false; allowedWallet[_wallet] = isAllowed; }
14,932
45
// total supply should be 0
assertEq(converter.totalSupply(), 0);
assertEq(converter.totalSupply(), 0);
41,325
51
// Ensures the target address is a prize strategy (has both canStartAward and canCompleteAward)
using SafeAwardable for address;
using SafeAwardable for address;
80,976
225
// load as string
returndatacopy(add(res, 32), 64, size) jump(exit)
returndatacopy(add(res, 32), 64, size) jump(exit)
28,756
384
// Create a new vote instanceThis function can only be called by the CRVoting owner_voteId ID of the new vote instance to be created_possibleOutcomes Number of possible outcomes for the new vote instance to be created/
function createVote(uint256 _voteId, uint8 _possibleOutcomes) external;
function createVote(uint256 _voteId, uint8 _possibleOutcomes) external;
19,599
97
// aTokens are 1:1
toTokenAmt = _fillQuote( fromToken, underlyingAsset, toInvest, _swapTarget, swapData ); IERC20(underlyingAsset).safeApprove( lendingPoolAddressProvider.getLendingPoolCore(),
toTokenAmt = _fillQuote( fromToken, underlyingAsset, toInvest, _swapTarget, swapData ); IERC20(underlyingAsset).safeApprove( lendingPoolAddressProvider.getLendingPoolCore(),
40,434
900
// Called whenever an action execution is failed./
event ActionFailed ( uint256 proposalId );
event ActionFailed ( uint256 proposalId );
2,283
6
// Log the return data for debugging or informational purposes
emit TransferData(data);
emit TransferData(data);
11,449
53
// Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); }
* together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); }
6,427
6
// weather = bytes32ToString(_data);
weather = _data;
weather = _data;
7,323
48
// mapping from Card ID to the current value stashed away for a future claimer
mapping (uint256 => uint256) public cardIdToStashedPayout;
mapping (uint256 => uint256) public cardIdToStashedPayout;
5,251
115
// GP: Add more data to events
event MisoInitFarmFactory(address sender); event FarmCreated(address indexed owner, address indexed addr, address token, uint256 startBlock, address farmTemplate); event FarmTemplateAdded(address newFarm, uint256 templateId); event FarmTemplateRemoved(address farm, uint256 templateId);
event MisoInitFarmFactory(address sender); event FarmCreated(address indexed owner, address indexed addr, address token, uint256 startBlock, address farmTemplate); event FarmTemplateAdded(address newFarm, uint256 templateId); event FarmTemplateRemoved(address farm, uint256 templateId);
27,093