comment
stringlengths
11
2.99k
function_code
stringlengths
165
3.15k
version
stringclasses
80 values
/** * @notice read the warning flag status of a contract address. * @param subjects An array of addresses being checked for a flag. * @return An array of bools where a true value for any flag indicates that * a flag was raised and a false value indicates that no flag was raised. */
function getFlags( address[] calldata subjects ) external view override checkAccess() returns (bool[] memory) { bool[] memory responses = new bool[](subjects.length); for (uint256 i = 0; i < subjects.length; i++) { responses[i] = flags[subjects[i]]; } return responses; ...
0.8.6
/** * @notice allows owner to disable the warning flags for multiple addresses. * Access is controlled by loweringAccessController, except for owner * who always has access. * @param subjects List of the contract addresses whose flag is being lowered */
function lowerFlags( address[] calldata subjects ) external override { require(_allowedToLowerFlags(), "Not allowed to lower flags"); for (uint256 i = 0; i < subjects.length; i++) { address subject = subjects[i]; _tryToLowerFlag(subject); } }
0.8.6
/// @dev getCurrentPriceLP returns the current exchange rate of LP token.
function getCurrentPriceLP() public override view returns (uint256 nowPrice) { (uint256 reserveA, uint256 reserveB) = getFloatReserve( address(0), WBTC_ADDR ); uint256 totalLPs = IBurnableToken(lpToken).totalSupply(); ...
0.7.5
/** * @dev Owner can withdraw the remaining ETH balance as long as amount of minted tokens is * less than 1 token (due to possible rounding leftovers) * */
function sweepVault(address payable _operator) public onlyPrimary { //1 initially minted + 1 possible rounding corrections require(communityToken.totalSupply() < 2 ether, 'Sweep available only if no minted tokens left'); require(address(this).balance > 0, 'Vault is empty'); _operator...
0.5.2
// A function used in case of strategy failure, possibly due to bug in the platform our strategy is using, governance can stop using it quick
function emergencyStopStrategy() external onlyGovernance { depositsOpen = false; if(currentStrategy != StabilizeStrategy(address(0)) && totalSupply() > 0){ currentStrategy.exit(); // Pulls all the tokens and accessory tokens from the strategy } currentStrategy = Stabili...
0.6.6
// -------------------- // Change the treasury address // --------------------
function startChangeStrategy(address _address) external onlyGovernance { _timelockStart = now; _timelockType = 2; _timelock_address = _address; _pendingStrategy = _address; if(totalSupply() == 0){ // Can change strategy with one call in this case fi...
0.6.6
/// @dev getDepositFeeRate returns deposit fees rate /// @param _token The address of target token. /// @param _amountOfFloat The amount of float.
function getDepositFeeRate(address _token, uint256 _amountOfFloat) public override view returns (uint256 depositFeeRate) { uint8 isFlip = _checkFlips(_token, _amountOfFloat); if (isFlip == 1) { depositFeeRate = _token == WBTC_ADDR ? depositFeesBPS ...
0.7.5
/// @dev getActiveNodes returns active nodes list (stakes and amount)
function getActiveNodes() public override view returns (bytes32[] memory) { uint256 nodeCount = 0; uint256 count = 0; // Seek all nodes for (uint256 i = 0; i < nodeAddrs.length; i++) { if (nodes[nodeAddrs[i]] != 0x0) { nodeCount = nodeCount.add(1); ...
0.7.5
/** * @dev Searches a sorted `array` and returns the first index that contains * a value greater or equal to `element`. If no such index exists (i.e. all * values in the array are strictly less than `element`), the array length is * returned. Time complexity O(log n). * * `array` is expected to be sorted in...
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { if (array.length == 0) { return 0; } uint256 low = 0; uint256 high = array.length; while (low < high) { uint256 mid = Math.average(low, high); ...
0.8.4
// DEPERECATED:
function getAllRatesForDEX( IERC20 fromToken, IERC20 toToken, uint256 amount, uint256 parts, uint256 disableFlags ) public view returns(uint256[] memory results) { results = new uint256[](parts); for (uint i = 0; i < parts; i++) { (results...
0.5.16
/** * @dev The main function of the contract. Should be called in the constructor function of the coin * * @param _guidelineSummary A summary of the guideline. The summary can be used as a title for * the guideline when it is retrieved and displayed on a front-end. * * @param _guideline The guideline itself...
function setGuideline(string memory _guidelineSummary, string memory _guideline) internal { /** * @dev creating a new struct instance of the type Guideline and storing it in memory. */ Guideline memory guideline = Guideline(_guidelineSummary, _guideline); /** * ...
0.8.11
/** * @dev function that converts an address into a string * NOTE: this function returns all lowercase letters. Ethereum addresses are not case sensitive. * However, because of this the address won't pass the optional checksum validation. */
function addressToString(address _address) internal pure returns(string memory) { bytes32 _bytes = bytes32(uint256(uint160(_address))); bytes memory HEX = "0123456789abcdef"; bytes memory _string = new bytes(42); _string[0] = '0'; _string[1] = 'x'; for(uint i = 0; i...
0.8.11
/// @dev _rewardsCollection collects tx rewards. /// @param _feesToken The token address for collection fees. /// @param _rewardsAmount The amount of rewards.
function _rewardsCollection(address _feesToken, uint256 _rewardsAmount) internal { if (_rewardsAmount == 0) return; if (_feesToken == lpToken) { feesLPTokensForNode = feesLPTokensForNode.add(_rewardsAmount); emit RewardsCollection(_feesToken, _rewardsAmount, 0, ...
0.7.5
// Update balance and/or total supply snapshots before the values are modified. This is implemented // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.
function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual override { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { // mint _updateAccountSnapshot(to); _updateTotalSupplyS...
0.8.4
/* function to send tokens to a given address */
function transfer(address _to, uint256 _value) returns (bool success){ require (now < startTime); //check if the crowdsale is already over require(msg.sender == owner && now < startTime + 1 years && safeSub(balanceOf[msg.sender],_value) < 1000000000); //prevent the owner of spending his share of token...
0.4.16
/* Transferfrom function*/
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require (now < startTime && _from!=owner); //check if the crowdsale is already over require(_from == owner && now < startTime + 1 years && safeSub(balanceOf[_from],_value) < 1000000000); var _allowance...
0.4.16
/* To be called when ICO is closed, burns the remaining tokens but the D-WALLET FREEZE VAULT (1000000000) and the ones reserved * for the bounty program (24000000). * anybody may burn the tokens after ICO ended, but only once (in case the owner holds more tokens in the future). * this ensures that the owner wi...
function burn(){ //if tokens have not been burned already and the ICO ended if(!burned && now>endTime){ uint difference = safeSub(balanceOf[owner], 1024000000);//checked for overflow above balanceOf[owner] = 1024000000; totalSupply = safeSub(totalSupply, difference); burned = tru...
0.4.16
// Getting egg price by id and quality
function getEggPrice(uint64 _petId, uint16 _quality) pure public returns(uint256 price) { uint64[6] memory egg_prices = [0, 150 finney, 600 finney, 3 ether, 12 ether, 600 finney]; uint8 egg = 2; if(_quality > 55000) egg = 1; if(_quality > 26000 && _quality < 26500)...
0.4.25
// Save rewards for all referral levels
function applyReward(uint64 _petId, uint16 _quality) internal { uint8[6] memory rewardByLevel = [0,250,120,60,30,15]; uint256 eggPrice = getEggPrice(_petId, _quality); uint64 _currentPetId = _petId; // make rewards for 5 levels for(uin...
0.4.25
/// @dev _addNode updates a staker's info. /// @param _addr The address of staker. /// @param _data The data of staker. /// @param _remove The flag to remove node.
function _addNode( address _addr, bytes32 _data, bool _remove ) internal returns (bool) { if (_remove) { delete nodes[_addr]; return true; } if (!isInList[_addr]) { nodeAddrs.push(_addr); isInList[_addr] = tru...
0.7.5
// Make synchronization, available for any sender
function sync() external whenNotPaused { // Checking synchronization status require(petSyncEnabled); // Get supply of pets from parent contract uint64 petSupply = uint64(parentInterface.totalSupply()); require(petSupply > lastPetId); // Synchro...
0.4.25
// Function of manual add pet
function addPet(uint64 _id) internal { (uint64 birthTime, uint256 genes, uint64 breedTimeout, uint16 quality, address owner) = parentInterface.getPet(_id); uint16 gradeQuality = quality; // For first pets - bonus quality in grade calculating if(_id < 244) gradeQuality...
0.4.25
// Function for automatic add pet
function automaticPetAdd(uint256 _price, uint16 _quality, uint64 _id) external { require(!petSyncEnabled); require(msg.sender == address(parentInterface)); lastPetId = _id; // Calculating seats in circle uint8 petGrade = getGradeByQuailty(_quality); ...
0.4.25
// Function for withdraw reward by pet owner
function withdrawReward(uint64 _petId) external whenNotPaused { // Get pet information PetInfo memory petInfo = petsInfo[_petId]; // Get owner of pet from pet contract and check it (uint64 birthTime, uint256 genes, uint64 breedTimeout, uint16 quality, address pet...
0.4.25
// Emergency reward sending by admin
function sendRewardByAdmin(uint64 _petId) external onlyOwner whenNotPaused { // Get pet information PetInfo memory petInfo = petsInfo[_petId]; // Get owner of pet from pet contract and check it (uint64 birthTime, uint256 genes, uint64 breedTimeout, uint16 quality,...
0.4.25
// call update BEFORE all transfers
function update(address whom) private { // safety checks if (lastUpdated[whom] >= allocations.length) return; uint myBalance = balanceOf(whom); if (myBalance == 0) return; uint supply = totalSupply(); // get data struct handy mapping(address=>uint) storage ...
0.5.6
// this function expects an allowance to have been made to allow tokens to be claimed to contract
function addRevenueInTokens(ERC20 token, uint value) public onlyOwner { allocations.length += 1; require(token.transferFrom(msg.sender, address(this),value),"cannot slurp the tokens"); if (!tokensShared[address(token)]) { tokensShared[address(token)] = true; tokenLis...
0.5.6
//int to string function.
function uint2str(uint256 _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint256 j = _i; uint256 len; while (j != 0) { len++; j /= 10; } bytes mem...
0.8.7
//OwnerMinting Function. The team is reserving 100 Mechs from the 10,000 collection for promotional purposes and internal rewards.
function ownerMint(uint256 tokenQuant) public payable virtual onlyOwner { require( tokenCounter + tokenQuant < maxSupply, "Would exceed max supply!" ); for (uint256 i; i < tokenQuant; i++) { _mint(msg.sender, tokenCounter); token...
0.8.7
//Function is named to generate a Method ID of 0x00007f6c to save gas
function whitelistMint_rhh(uint256 tokenQuant, bytes memory _whitelistToken) public payable virtual { require( (liveStatus == MintPhase.Whitelist) && (whitelistSigner == recoverSigner_94g(_whitelistToken)), "Either Whitelist P...
0.8.7
// Separating mint phases to reduce operations
function publicMint_1VS(uint256 tokenQuant) public payable virtual { require( liveStatus == MintPhase.Open, "Mint Phase is not open to the public yet!" ); require( tokenCounter + tokenQuant < maxSupply, "Would exceed max supply" )...
0.8.7
//Set the base path on Pinata.
function reveal(string memory base) public onlyOwner { require( mutableMetadata, // Check to make sure the collection hasn't been frozen before allowing the metadata to change "Metadata is frozen on the blockchain forever" ); baseURI = base; emit executedRev...
0.8.7
/** * @notice Creates the Chainlink request * @dev Stores the hash of the params as the on-chain commitment for the request. * Emits OracleRequest event for the Chainlink node to detect. * @param _sender The sender of the request * @param _payment The amount of payment given (specified in wei) * @param _spe...
function oracleRequest( address _sender, uint256 _payment, bytes32 _specId, address _callbackAddress, bytes4 _callbackFunctionId, uint256 _nonce, uint256 _dataVersion, bytes _data ) external onlyLINK checkCallbackAddress(_callbackAddress) { bytes32 reque...
0.4.24
//Extract the signer address for the whitelist verification.
function recoverSigner_94g(bytes memory _signature) internal view returns (address) { (bytes32 r, bytes32 s, uint8 v) = splitSignature(_signature); bytes32 senderhash = keccak256(abi.encodePacked(msg.sender)); bytes32 finalhash = keccak256( abi.enc...
0.8.7
//Extract the components of the whitelist signature.
function splitSignature(bytes memory sig) public pure returns ( bytes32 r, bytes32 s, uint8 v ) { require(sig.length == 65, "invalid signature length"); assembly { r := mload(add(sig, 32)) s := ml...
0.8.7
// ============ Swap ============
function dodoSwapV2ETHToToken( address toToken, uint256 minReturnAmount, address[] memory dodoPairs, uint256 directions, bool isIncentive, uint256 deadLine ) external override payable judgeExpired(deadLine) returns (...
0.6.9
// Deposit LP tokens to VENIAdmin for VENI allocation.
function deposit(uint256 _pid, uint256 _amount) public { require(!deposit_Paused , "Deposit is currently not possible."); PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256...
0.6.12
/** * @notice Called by the Chainlink node to fulfill requests * @dev Given params must hash back to the commitment stored from `oracleRequest`. * Will call the callback address' callback function without bubbling up error * checking in a `require` so that the node can get paid. * @param _requestId The fulfil...
function fulfillOracleRequest( bytes32 _requestId, uint256 _payment, address _callbackAddress, bytes4 _callbackFunctionId, uint256 _expiration, bytes32 _data ) external onlyAuthorizedNode isValidRequest(_requestId) returns (bool) { bytes32 paramsHash = keccak...
0.4.24
// Withdraw LP tokens from VENIAdmin.
function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accVENIPerSha...
0.6.12
// add total stake amount
function GetTotalStakeAmount() external view returns (uint256) { uint256 TotalMount = 0; for (uint256 i = 0; i < poolInfo.length; i++) { PoolInfo storage pool = poolInfo[i]; if(pool.allocPoint > 0) { uint256 multiplier = getMultiplie...
0.6.12
//Single Token Stake -----------------------------------------------------------------------------------
function GetTotalStakeAmount_single(uint256 _pid) external view returns (uint256) { uint256 TotalMount = 0; SinglePoolInfo storage pool = poolInfo_single[_pid]; uint256 currentBlock = block.number; if(pool.setEndBlock && currentBlock > pool.singleTokenEndBlock) { cur...
0.6.12
//============ CrowdPooling Functions (create & bid) ============
function createCrowdPooling( address baseToken, address quoteToken, uint256 baseInAmount, uint256[] memory timeLine, uint256[] memory valueList, bool isOpenTWAP, uint256 deadLine ) external override payable preventReentrant judgeExpired(deadLine) retur...
0.6.9
/** * @notice Allows requesters to cancel requests sent to this oracle contract. Will transfer the LINK * sent for the request back to the requester's address. * @dev Given params must hash to a commitment stored on the contract in order for the request to be valid * Emits CancelOracleRequest event. * @param ...
function cancelOracleRequest( bytes32 _requestId, uint256 _payment, bytes4 _callbackFunc, uint256 _expiration ) external { bytes32 paramsHash = keccak256( abi.encodePacked( _payment, msg.sender, _callbackFunc, _expiration) ); require(param...
0.4.24
/** * @dev Internal function to transfer ownership of a given token ID to another address. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * @param from current owner of the token * @param to address to receive the ownership of the given token ID * @param tokenId uint256 ID of the ...
function _transferFrom(address from, address to, uint256 tokenId) internal { require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _clearApproval(tokenId); _ownedTokensCount[from].decreme...
0.5.7
// View function to see pending VENI on frontend single token.
function pendingVENI_single(uint256 _pid, address _user) external view returns (uint256) { SinglePoolInfo storage pool = poolInfo_single[_pid]; UserInfo storage user = userInfo_single[_pid][_user]; uint256 accVENIPerShare = pool.accVENIPerShare; uint256 sSupply = pool.sToken.balanceO...
0.6.12
/** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use {ERC721-_burn} instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned */
function _burn(address owner, uint256 tokenId) internal { super._burn(owner, tokenId); _removeTokenFromOwnerEnumeration(owner, tokenId); // Since tokenId will be deleted, we can clear its slot in _ownedTokensIndex to trigger a gas refund _ownedTokensIndex[tokenId] = 0; _...
0.5.7
// IFrogLand
function canMint(uint256 quantity) public view override returns (bool) { require(saleIsActive, "sale hasn't started"); require(!presaleIsActive, 'only presale'); require(totalSupply().add(quantity) <= MAX_TOKENS, 'quantity exceeds supply'); require(_publicMinted.add(quantity) <= maxMinta...
0.8.4
// IFrogLandAdmin
function mintToAddress(uint256 quantity, address to) external override onlyOwner { require(totalSupply().add(quantity) <= MAX_TOKENS, 'quantity exceeds supply'); require(_adminMinted.add(quantity) <= maxAdminSupply, 'quantity exceeds mintable'); for (uint256 i = 0; i < quantity; i++) { ...
0.8.4
//whitelist
function addToWhitelist(address[] calldata addresses) external override onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { require(addresses[i] != address(0), "Can't add the null address"); _Whitelist[addresses[i]] = true; _WhitelistClaimed[addresses[i]] > 0 ? _WhitelistClaimed[addre...
0.8.9
//firestarter tier 1
function addToFirestarter1(address[] calldata addresses) external override onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { require(addresses[i] != address(0), "Can't add the null address"); _Firestarter1[addresses[i]] = true; _Firestarter1Claimed[addresses[i]] > 0 ? _Firestarter1C...
0.8.9
//firestarter tier 2
function addToFirestarter2(address[] calldata addresses) external override onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { require(addresses[i] != address(0), "Can't add the null address"); _Firestarter2[addresses[i]] = true; _Firestarter2Claimed[addresses[i]] > 0 ? _Firestarter2C...
0.8.9
//airdrop for original contract: 0xab20d7517e46a227d0dc7da66e06ea8b68d717e1 // no limit due to to airdrop going directly to the 447 owners
function airdrop(address[] calldata to) external onlyOwner { require(totalSupply() < NFT_MAX, 'All tokens have been minted'); for(uint256 i = 0; i < to.length; i++) { uint256 tokenId = totalSupply() + 1; totalAirdropSupply += 1; _safeMint(to[i], tokenId); } }
0.8.9
//reserve // no limit due to to airdrop going directly to addresses
function reserve(address[] calldata to) external onlyOwner { require(totalSupply() < NFT_MAX, 'All tokens have been minted'); for(uint256 i = 0; i < to.length; i++) { uint256 tokenId = totalSupply() + 1; totalReserveSupply += 1; _safeMint(to[i], tokenId); } }
0.8.9
/** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */
function _setOwnersExplicit(uint256 quantity) internal { require(quantity != 0, "quantity must be nonzero"); require(currentIndex != 0, "no tokens minted yet"); uint256 _nextOwnerToExplicitlySet = nextOwnerToExplicitlySet; require(_nextOwnerToExplicitlySet < currentIndex, "all ownerships have be...
0.8.11
// ------------------------------------------------------------------------ // 15,000 M10 Tokens per 1 ETH // ------------------------------------------------------------------------
function () public payable { require(now >= startDate && now <= endDate); uint tokens; if (now <= bonusEnds) { tokens = msg.value * 20000; } else { tokens = msg.value * 15000; } balances[msg.sender] = safeAdd(balances[msg.sender], tokens); ...
0.4.24
/** * @notice called by oracles when they have witnessed a need to update * @param _roundId is the ID of the round this submission pertains to * @param _submission is the updated data that the oracle is submitting */
function submit(uint256 _roundId, int256 _submission) external { bytes memory error = validateOracleRound(msg.sender, uint32(_roundId)); require(_submission >= minSubmissionValue, "value below minSubmissionValue"); require(_submission <= maxSubmissionValue, "value above maxSubmissionValue"); requi...
0.6.6
/** * @notice called by the owner to remove and add new oracles as well as * update the round related parameters that pertain to total oracle count * @param _removed is the list of addresses for the new Oracles being removed * @param _added is the list of addresses for the new Oracles being added * @param _addedAd...
function changeOracles( address[] calldata _removed, address[] calldata _added, address[] calldata _addedAdmins, uint32 _minSubmissions, uint32 _maxSubmissions, uint32 _restartDelay ) external onlyOwner() { for (uint256 i = 0; i < _removed.length; i++) { removeOracle(_remov...
0.6.6
/** * @notice update the round and payment related parameters for subsequent * rounds * @param _paymentAmount is the payment amount for subsequent rounds * @param _minSubmissions is the new minimum submission count for each round * @param _maxSubmissions is the new maximum submission count for each round * @param...
function updateFutureRounds( uint128 _paymentAmount, uint32 _minSubmissions, uint32 _maxSubmissions, uint32 _restartDelay, uint32 _timeout ) public onlyOwner() { uint32 oracleNum = oracleCount(); // Save on storage reads require(_maxSubmissions >= _minSubmissions, "max must equal...
0.6.6
/** * @notice get data about a round. Consumers are encouraged to check * that they're receiving fresh data by inspecting the updatedAt and * answeredInRound return values. * @param _roundId the round ID to retrieve the round data for * @return roundId is the round ID for which data was retrieved * @return answer...
function getRoundData(uint80 _roundId) public view virtual override returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { Round memory r = rounds[uint32(_roundId)]; require(r.answeredInRound > 0 && valid...
0.6.6
/** * @notice transfers the oracle's LINK to another address. Can only be called * by the oracle's admin. * @param _oracle is the oracle whose LINK is transferred * @param _recipient is the address to send the LINK to * @param _amount is the amount of LINK to send */
function withdrawPayment(address _oracle, address _recipient, uint256 _amount) external { require(oracles[_oracle].admin == msg.sender, "only callable by admin"); // Safe to downcast _amount because the total amount of LINK is less than 2^128. uint128 amount = uint128(_amount); uint128 available ...
0.6.6
/** * @notice allows non-oracles to request a new round */
function requestNewRound() external returns (uint80) { require(requesters[msg.sender].authorized, "not authorized requester"); uint32 current = reportingRoundId; require(rounds[current].updatedAt > 0 || timedOut(current), "prev round must be supersedable"); uint32 newRoundId = current.add(1)...
0.6.6
/** * @notice allows the owner to specify new non-oracles to start new rounds * @param _requester is the address to set permissions for * @param _authorized is a boolean specifying whether they can start new rounds or not * @param _delay is the number of rounds the requester must wait before starting another round ...
function setRequesterPermissions(address _requester, bool _authorized, uint32 _delay) external onlyOwner() { if (requesters[_requester].authorized == _authorized) return; if (_authorized) { requesters[_requester].authorized = _authorized; requesters[_requester].delay = _delay; } else ...
0.6.6
/** * @notice a method to provide all current info oracles need. Intended only * only to be callable by oracles. Not for use by contracts to read state. * @param _oracle the address to look up information for. */
function oracleRoundState(address _oracle, uint32 _queriedRoundId) external view returns ( bool _eligibleToSubmit, uint32 _roundId, int256 _latestSubmission, uint64 _startedAt, uint64 _timeout, uint128 _availableFunds, uint8 _oracleCount, uint128 _paymentAmoun...
0.6.6
/** * Private */
function initializeNewRound(uint32 _roundId) private { updateTimedOutRoundInfo(_roundId.sub(1)); reportingRoundId = _roundId; RoundDetails memory nextDetails = RoundDetails( new int256[](0), maxSubmissionCount, minSubmissionCount, timeout, paymentAmount ); detail...
0.6.6
/** * Get the array of token for owner. */
function tokensOfOwner(address owner) external view returns(uint256[] memory) { uint256 tokenCount = balanceOf(owner); if (tokenCount == 0) { return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 id = 0; for...
0.8.0
/** * Create Strong Node & Mint SNN */
function mint() external payable { require(isSale, "Sale must be active to mint"); uint256 supply = _owners.length; uint256 naasRequestingFeeInWei = strongService.naasRequestingFeeInWei(); uint256 naasStrongFeeInWei = strongService.naasStrongFeeInWei(); ...
0.8.0
/// @dev verify is used for check signature.
function verify( uint256 curveId, bytes32 signature, bytes32 groupKeyX, bytes32 groupKeyY, bytes32 randomPointX, bytes32 randomPointY, bytes32 message ) external returns (bool) { require(verifierMap[curveId] != address(0), "curveId not correct...
0.4.26
// Check if the amount the owners are attempting to withdraw is within their current allowance
function amountIsWithinOwnersAllowance(uint256 amountToWithdraw) internal view returns (bool) { if (now - icoEndDate >= yearLength * 2) return true; uint256 totalFundsWithdrawnAfterThisTransaction = fundsWithdrawnByOwners + amountToWithdraw; bool withinAllowance = totalFundsWithdrawnAfterThisTrans...
0.4.19
// Buy keys
function bid() public payable blabla { uint _minLeaderAmount = pot.mul(MIN_LEADER_FRAC_TOP).div(MIN_LEADER_FRAC_BOT); uint _bidAmountToCommunity = msg.value.mul(FRAC_TOP).div(FRAC_BOT); uint _bidAmountToDividendFund = msg.value.mul(DIVIDEND_FUND_FRAC_TOP).div(DIVIDEND_FUND_FRAC_BOT); ...
0.4.19
// Sell keys
function withdrawDividends() public { require(dividendShares[msg.sender] > 0); uint _dividendShares = dividendShares[msg.sender]; assert(_dividendShares <= totalDividendShares); uint _amount = dividendFund.mul(_dividendShares).div(totalDividendShares); assert(_amount <= this.balance)...
0.4.19
/// @notice allow to mint tokens
function mint(address _holder, uint256 _tokens) public onlyMintingAgents() { require(allowedMinting == true && totalSupply_.add(_tokens) <= maxSupply); totalSupply_ = totalSupply_.add(_tokens); balances[_holder] = balanceOf(_holder).add(_tokens); if (totalSupply_ == maxSupply) ...
0.4.24
/// @dev Alias of sell() and withdraw().
function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if (_tokens > 0) sell(_tokens); // capitulation withdraw(); }
0.4.24
/// @dev Withdraws all of the callers earnings.
function withdraw() onlyStronghands public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); ...
0.4.24
/** * @dev Transfer tokens from the caller to a new holder. */
function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw ...
0.4.24
/// @dev Return the sell price of 1 individual token.
function sellPrice() public view returns (uint256) { // our calculation relies on the token supply, so we need supply. Doh. if (tokenSupply_ == 0) { return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); ...
0.4.24
/// @dev Function for getting the current exitFee
function exitFee() public view returns (uint8) { if (startTime==0){ return startExitFee_; } if ( now < startTime) { return 0; } uint256 secondsPassed = now - startTime; if (secondsPassed >= exitFeeFallDuration_) { return finalExit...
0.4.24
/** * Adds Rabbits, Foxes and Hunters to their respective safe homes. * @param account the address of the staker * @param tokenIds the IDs of the Rabbit and Foxes to stake */
function stakeTokens(address account, uint16[] calldata tokenIds) external whenNotPaused nonReentrant _updateEarnings { require(account == msg.sender || msg.sender == address(foxNFT), "only owned tokens can be staked"); for (uint16 i = 0; i < tokenIds.length; i++) { // Transfer into safe house if (...
0.8.10
/** * @dev Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */
function tokensToEthereum_(uint256 _tokens) internal view returns (uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ...
0.4.24
/// @dev This is where all your gas goes.
function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } }
0.4.24
/** * Add Fox to the Den. * @param account the address of the staker * @param tokenId the ID of the Fox */
function _addFoxToDen(address account, uint16 tokenId) internal { uint8 cunning = _getAdvantagePoints(tokenId); totalCunningPointsStaked += cunning; // Store fox by rating foxHierarchy[tokenId] = uint16(foxStakeByCunning[cunning].length); // Add fox to their cunning group foxStakeByCunning[cunni...
0.8.10
/** * Adds Hunter to the Cabin. * @param account the address of the staker * @param tokenId the ID of the Hunter */
function _addHunterToCabin(address account, uint16 tokenId) internal { uint8 marksman = _getAdvantagePoints(tokenId); totalMarksmanPointsStaked += marksman; // Store hunter by rating hunterHierarchy[tokenId] = uint16(hunterStakeByMarksman[marksman].length); // Add hunter to their marksman group ...
0.8.10
/* Users can claim ETH by themselves if they want to in case of ETH failure */
function claimEthIfFailed(){ if (block.number <= endBlock || totalEthRaised >= minEthToRaise) throw; // Check if Crowdsale has failed if (participantContribution[msg.sender] == 0) throw; // Check if user has participated if (hasClaimedEthWhenFail[msg.sender]) throw; ...
0.4.17
/* Owner can return eth for multiple users in one call */
function batchReturnEthIfFailed(uint256 _numberOfReturns) onlyOwner{ if (block.number < endBlock || totalEthRaised >= minEthToRaise) throw; // Check if Crowdsale failed address currentParticipantAddress; uint256 contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++){ ...
0.4.17
/* Withdraw funds from contract */
function withdrawEther() onlyOwner{ if (this.balance == 0) throw; // Check if there is balance on the contract if (totalEthRaised < minEthToRaise) throw; // Check if minEthToRaise treshold is exceeded ...
0.4.17
/* Withdraw remaining balance to manually return where contract send has failed */
function withdrawRemainingBalanceForManualRecovery() onlyOwner{ if (this.balance == 0) throw; // Check if there is balance on the contract if (block.number < endBlock) throw; // Check if Crowdsale failed if (part...
0.4.17
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'ImpulsevenSwapV2: OVERFLOW'); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimesta...
0.5.16
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IImpulsevenSwapV2Factory(factory).feeTo(); feeOn = feeTo != address(0); uint _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint rootK ...
0.5.16
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external lock returns (uint liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_re...
0.5.16
/** * Realize $CARROT earnings and optionally unstake tokens. * @param tokenIds the IDs of the tokens to claim earnings from * @param unstake whether or not to unstake ALL of the tokens listed in tokenIds * @param membership wheather user is membership or not * @param seed account seed * @param 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 rew...
0.8.10
/** * @dev onlyManyOwners modifier helper */
function checkHowManyOwners(uint howMany) internal returns(bool) { if (insideCallSender == msg.sender) { require(howMany <= insideCallCount, "checkHowManyOwners: nested owners modifier check require more owners"); return true; } uint ownerIndex = ownersIndices[msg....
0.6.12
/** * @dev Used to delete cancelled or performed operation * @param operation defines which operation to delete */
function deleteOperation(bytes32 operation) internal { uint index = allOperationsIndicies[operation]; if (index < allOperations.length - 1) { // Not last allOperations[index] = allOperations[allOperations.length - 1]; allOperationsIndicies[allOperations[index]] = index; ...
0.6.12
/** * @dev Allows owners to change their mind by cacnelling votesMaskByOperation operations * @param operation defines which operation to delete */
function cancelPending(bytes32 operation) public onlyAnyOwner { uint ownerIndex = ownersIndices[msg.sender] - 1; require((votesMaskByOperation[operation] & (2 ** ownerIndex)) != 0, "cancelPending: operation not found for this user"); votesMaskByOperation[operation] &= ~(2 ** ownerIndex); ...
0.6.12
/** * @dev Allows owners to change ownership * @param newOwners defines array of addresses of new owners * @param newHowManyOwnersDecide defines how many owners can decide */
function transferOwnershipWithHowMany(address[] memory newOwners, uint256 newHowManyOwnersDecide) public onlyManyOwners { require(newOwners.length > 0, "transferOwnershipWithHowMany: owners array is empty"); require(newOwners.length <= 256, "transferOwnershipWithHowMany: owners count is greater then 2...
0.6.12
/// @notice this function is used to send ES as prepaid for PET /// @dev some ES already in prepaid required /// @param _addresses: address array to send prepaid ES for PET /// @param _amounts: prepaid ES for PET amounts to send to corresponding addresses
function sendPrepaidESDifferent( address[] memory _addresses, uint256[] memory _amounts ) public { for(uint256 i = 0; i < _addresses.length; i++) { /// @notice subtracting amount from sender prepaidES prepaidES[msg.sender] = prepaidES[msg.sender].sub(_amounts[i]); /// @notice th...
0.5.16
/// @notice this function is used by anyone to create a new PET /// @param _planId: id of PET in staker portfolio /// @param _monthlyCommitmentAmount: PET monthly commitment amount in exaES
function newPET( uint256 _planId, uint256 _monthlyCommitmentAmount ) public { /// @notice enforcing that the plan should be active require( petPlans[_planId].isPlanActive , 'PET plan is not active' ); /// @notice enforcing that monthly commitment by the staker should be ...
0.5.16
/// @notice this function is used by deployer to create plans for new PETs /// @param _minimumMonthlyCommitmentAmount: minimum PET monthly amount in exaES /// @param _monthlyBenefitFactorPerThousand: this is per 1000; i.e 200 for 20%
function createPETPlan( uint256 _minimumMonthlyCommitmentAmount, uint256 _monthlyBenefitFactorPerThousand ) public onlyDeployer { /// @notice adding the petPlan to storage petPlans.push(PETPlan({ isPlanActive: true, minimumMonthlyCommitmentAmount: _minimumMonthlyCommitmentAmount, ...
0.5.16
/// @notice this function is used to update nominee status of a wallet address in PET /// @param _petId: id of PET in staker portfolio. /// @param _nomineeAddress: eth wallet address of nominee. /// @param _newNomineeStatus: true or false, whether this should be a nominee or not.
function toogleNominee( uint256 _petId, address _nomineeAddress, bool _newNomineeStatus ) public { /// @notice updating nominee status pets[msg.sender][_petId].nominees[_nomineeAddress] = _newNomineeStatus; /// @notice emiting event for UI and other applications emit NomineeUpdat...
0.5.16
/// @notice this function is used to update appointee status of a wallet address in PET /// @param _petId: id of PET in staker portfolio. /// @param _appointeeAddress: eth wallet address of appointee. /// @param _newAppointeeStatus: true or false, should this have appointee rights or not.
function toogleAppointee( uint256 _petId, address _appointeeAddress, bool _newAppointeeStatus ) public { PET storage _pet = pets[msg.sender][_petId]; /// @notice if not an appointee already and _newAppointeeStatus is true, adding appointee if(!_pet.appointees[_appointeeAddress] && _ne...
0.5.16
/// @notice this function is used by appointee to vote that nominees can withdraw early /// @dev need to be appointee, set by staker themselves /// @param _stakerAddress: address of initiater of this PET. /// @param _petId: id of PET in staker portfolio.
function appointeeVote( address _stakerAddress, uint256 _petId ) public { PET storage _pet = pets[_stakerAddress][_petId]; /// @notice checking if appointee has rights to cast a vote require(_pet.appointees[msg.sender] , 'should be appointee to cast vote' ); /// @notice ...
0.5.16
/// @notice this function is used by contract to get nominee's allowed timestamp /// @param _stakerAddress: address of staker who has a PET /// @param _petId: id of PET in staker address portfolio /// @param _annuityMonthId: this is the month for which timestamp to find /// @return nominee allowed timestamp
function getNomineeAllowedTimestamp( address _stakerAddress, uint256 _petId, uint256 _annuityMonthId ) public view returns (uint256) { PET storage _pet = pets[_stakerAddress][_petId]; uint256 _allowedTimestamp = _pet.initTimestamp + (12 + _annuityMonthId - 1) * EARTH_SECONDS_IN_MONTH;...
0.5.16