comment
stringlengths
11
2.99k
function_code
stringlengths
165
3.15k
version
stringclasses
80 values
/// @param pos Hypervisor address /// @param deposit0Max Amount of maximum deposit amounts of token0 /// @param deposit1Max Amount of maximum deposit amounts of token1 /// @param maxTotalSupply Maximum total suppoy of hypervisor
function customDeposit( address pos, uint256 deposit0Max, uint256 deposit1Max, uint256 maxTotalSupply ) external onlyOwner onlyAddedPosition(pos) { Position storage p = positions[pos]; p.deposit0Max = deposit0Max; p.deposit1Max = deposit1Max; p.maxTotalSupply = maxTotalSupply; emit...
0.7.6
/// @notice Append whitelist to hypervisor /// @param pos Hypervisor Address /// @param listed Address array to add in whitelist
function appendList(address pos, address[] memory listed) external onlyOwner onlyAddedPosition(pos) { Position storage p = positions[pos]; for (uint8 i; i < listed.length; i++) { p.list[listed[i]] = true; } emit ListAppended(pos, listed); }
0.7.6
/* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and ...
function clearCNDAO() public onlyOwner() { /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct ...
0.5.17
// This will return the stats for a ponzi friend // returns(ponziFriendId, parent, amoutPlayed, amountEarned)
function getPonziFriend(address _addr) public view returns(uint, uint, uint256, uint256, uint, uint, uint) { uint pzfId = ponziFriendsToId[_addr]; if(pzfId == 0) { return(0, 0, 0, 0, 0, 0, 0); } else { return(pzfId, ponziFriends[pzfId].parent, ponziFriends[pzfId].amo...
0.4.24
// endregion // Claim a token using Mintpass ticket
function claim(uint amount) external { require(isClaimingAvailable, "Claiming is not available"); require(amount <= claimLimit, "All mintpasses were claimed"); uint tickets = mintPassContract.balanceOf(msg.sender, TICKET_ID); require(claimedWithMintpass[msg.sender] + amount <= tick...
0.8.4
// Main sale mint
function mint(uint amount) external payable { require(isMintingAvailable, "Minting is not available"); require(tokensMinted + amount <= MAX_SUPPLY - reservedTokensLimit - claimLimit, "Tokens supply reached limit"); require(amount > 0 && amount <= MINT_PER_TX_LIMIT, "Can only mint 20 tokens at...
0.8.4
// Presale mint
function presaleMint(uint amount) external payable { require(isPresaleAvailable, "Presale is not available"); require(presaleTokensMinted + amount <= presaleTokensLimit, "Presale tokens supply reached limit"); // Only presale token validation require(tokensMinted + amount <= MAX_SUPPLY - rese...
0.8.4
//////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////// //////////// //////////// Internal functions that write to //////////// //////////// state variables //////////// //////////// ...
function _addParticipant(address _newParticipant) private { // Add the participant to the list, but only if they are not 0x0 and they are not already in the list. if (_newParticipant != address(0x0) && addressToParticipantsArrayIndex[_newParticipant] == 0) { addressToPartici...
0.5.4
//////////////////////////////////// //////// Internal functions to change ownership of a prime
function _removePrimeFromOwnerPrimesArray(uint256 _prime) private { bytes32 numberdata = numberToNumberdata[_prime]; uint256[] storage ownerPrimes = ownerToPrimes[numberdataToOwner(numberdata)]; uint256 primeIndex = numberdataToOwnerPrimesIndex(numberdata); // Move the...
0.5.4
/*function _numberdataSetOwner(uint256 _number, address _owner) private { bytes32 numberdata = numberToNumberdata[_number]; numberdata &= ~NUMBERDATA_OWNER_ADDRESS_MASK; numberdata |= bytes32(uint256(uint160(_owner))) << NUMBERDATA_OWNER_ADDRESS_SHIFT; numberToNumberdata[_number] = numberdata; }*/
function _numberdataSetOwnerAndOwnerPrimesIndex(uint256 _number, address _owner, uint40 _ownerPrimesIndex) private { bytes32 numberdata = numberToNumberdata[_number]; numberdata &= ~NUMBERDATA_OWNER_ADDRESS_MASK; numberdata |= bytes32(uint256(uint160(_owner))) << NUMBERDATA_OWN...
0.5.4
// https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
function sqrtRoundedDown(uint256 x) private pure returns (uint256 y) { if (x == ~uint256(0)) return 340282366920938463463374607431768211455; uint256 z = (x + 1) >> 1; y = x; while (z < y) { y = z; z = ((x / z) + z) >> 1; } ...
0.5.4
// NTuple mersenne primes: // n=0 => primes returns [] // n=1 => mersenne primes of form 2^p-1 returns [p] // n=2 => double mersenne primes of form 2^(2^p-1)-1 returns [2^p-1, p] // n=3 => triple mersenne primes of form 2^(2^(2^p-1)-1)-1 returns [2^...
function isNTupleMersennePrime(uint256 _number, uint256 _n) external view returns (Booly _result, uint256[] memory _powers) { _powers = new uint256[](_n); // Prevent overflow on _number+1 if (_number+1 < _number) return (UNKNOWN, _powers); _result = isPrime(_...
0.5.4
// A good prime's square is greater than the product of all equally distant (by index) primes
function isGoodPrime(uint256 _number) external view returns (Booly) { // 2 is defined not to be a good prime. if (_number == 2) return DEFINITELY_NOT; Booly primality = isPrime(_number); if (primality == DEFINITELY) { uint256 index = numberdataToA...
0.5.4
// Factorial primes are of the form n!+delta where delta = +1 or delta = -1
function isFactorialPrime(uint256 _number) external view returns (Booly _result, uint256 _n, int256 _delta) { // Prevent underflow on _number-1 if (_number == 0) return (DEFINITELY_NOT, 0, 0); // Prevent overflow on _number+1 if (_number == ~uint256(0)) return (DEFINIT...
0.5.4
// Cullen primes are of the form n * 2^n + 1
function isCullenPrime(uint256 _number) external pure returns (Booly _result, uint256 _n) { // There are only two cullen primes that fit in a 256-bit integer if (_number == 3) // n = 1 { return (DEFINITELY, 1); } else if (_number == 39305063412410223286956...
0.5.4
// Fermat primes are of the form 2^(2^n)+1 // Conjecturally, 3, 5, 17, 257, 65537 are the only ones
function isFermatPrime(uint256 _number) external view returns (Booly result, uint256 _2_pow_n, uint256 _n) { // Prevent underflow on _number-1 if (_number == 0) return (DEFINITELY_NOT, 0, 0); Booly primality = isPrime(_number); if (primality == DEFI...
0.5.4
// Super-primes are primes with a prime index in the sequence of prime numbers. (indexed starting with 1)
function isSuperPrime(uint256 _number) public view returns (Booly _result, uint256 _indexStartAtOne) { Booly primality = isPrime(_number); if (primality == DEFINITELY) { _indexStartAtOne = numberdataToAllPrimesIndex(numberToNumberdata[_number]) + 1; _result = is...
0.5.4
//////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////// //////////// //////////// Math functions //////////// //////////// //////////// ///////////////...
function reverseFactorial(uint256 _number) private pure returns (uint256 output, bool success) { // 0 = immediate failure if (_number == 0) return (0, false); uint256 divisor = 1; while (_number > 1) { divisor++; uint256 remainder = _...
0.5.4
// Performs a log2 on a power of 2. // This function will throw if the input was not a power of 2.
function log2ofPowerOf2(uint256 _powerOf2) private pure returns (uint256) { require(_powerOf2 != 0, "log2ofPowerOf2 error: 0 is not a power of 2"); uint256 iterations = 0; while (true) { if (_powerOf2 == 1) return iterations; require((_powerOf2 & 1) == ...
0.5.4
// TRY_POW_MOD function defines 0^0 % n = 1
function TRY_POW_MOD(uint256 _base, uint256 _power, uint256 _modulus) private pure returns (uint256 result, bool success) { if (_modulus == 0) return (0, false); bool mulSuccess; _base %= _modulus; result = 1; while (_power > 0) { if (_po...
0.5.4
//////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////// //////////// //////////// Trading view functions //////////// //////////// //////////// ///////////////...
function countPrimeBuyOrders(uint256 _prime) external view returns (uint256 _amountOfBuyOrders) { _amountOfBuyOrders = 0; BuyOrder[] storage buyOrders = primeToBuyOrders[_prime]; for (uint256 i=0; i<buyOrders.length; i++) { if (buyOrders[i].buyer != addres...
0.5.4
/// @notice the function to mint a new vault /// @param _name the desired name of the vault /// @param _symbol the desired sumbol of the vault /// @param _token the ERC721 token address fo the NFT /// @param _id the uint256 ID of the token /// @param _listPrice the initial price of the NFT /// @return the ID of the vau...
function mint(string memory _name, string memory _symbol, address _token, uint256 _id, uint256 _supply, uint256 _listPrice, uint256 _fee) external whenNotPaused returns(uint256) { TokenVault vault = new TokenVault(settings, msg.sender, _token, _id, _supply, _listPrice, _fee, _name, _symbol); emit Mint(_token, ...
0.8.0
/* ############################################################ The pay interest function is called by an administrator ------------------- */
function payInterest(address recipient, uint256 interestRate) { if ((msg.sender == creator || msg.sender == Owner0 || msg.sender == Owner1)) { uint256 weiAmount = calculateInterest(recipient, interestRate); interestPaid[recipient] += weiAmount; payout(recipient, weiAmount...
0.4.16
/** * Set an upgrade agent that handles */
function setUpgradeAgent(address agent) external { if(!canUpgrade()) { // The token is not yet in a state that we could think upgrading throw; } if (agent == 0x0) throw; // Only a master can designate the next agent if (msg.sender != upgradeMaster) throw; ...
0.4.8
/** * Set the contract that can call release and make the token transferable. */
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public { // Already set if(releaseAgent != 0) { throw; } // We don't do interface check here as we might want to a normal wallet address to act as a release agent releaseAgent = addr; }
0.4.8
/** * Construct the token. * * This token must be created through a team multisig wallet, so that it is owned by that wallet. */
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply) { // Create from team multisig owner = msg.sender; // Initially set the upgrade master same as owner upgradeMaster = owner; name = _name; symbol = _symbol; totalSupply = _initialSupply; // Create...
0.4.8
/// @dev Returns if Safe transaction is a valid daily limit transaction. /// @param token Address of the token that should be transfered (0 for Ether) /// @param to Address to which the tokens should be transfered /// @param amount Amount of tokens (or Ether) that should be transfered /// @return Returns if transaction...
function executeDailyLimit(address token, address to, uint256 amount) public { // Only Safe owners are allowed to execute daily limit transactions. require(OwnerManager(manager).isOwner(msg.sender), "Method can only be called by an owner"); require(to != 0, "Invalid to address p...
0.4.24
//Sends tokens from sender's account
function transfer(address _to, uint256 _value) returns (bool success) { if ((balance[msg.sender] >= _value) && (balance[_to] + _value > balance[_to])) { balance[msg.sender] -= _value; balance[_to] += _value; Transfer(msg.sender, _to, _value); return true; ...
0.4.18
//Transfers tokens from an approved account
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if ((balance[_from] >= _value) && (allowed[_from][msg.sender] >= _value) && (balance[_to] + _value > balance[_to])) { balance[_to] += _value; balance[_from] -= _value; allowed[_from...
0.4.18
/// @dev interal fuction to calculate and mint fees
function _claimFees() internal { require(auctionState != State.ended, "claim:cannot claim after auction ends"); // get how much in fees the curator would make in a year uint256 currentAnnualFee = fee * totalSupply() / 1000; // get how much that is per second; uint256 feePerSeco...
0.8.0
/// @notice an internal function used to update sender and receivers price on token transfer /// @param _from the ERC20 token sender /// @param _to the ERC20 token receiver /// @param _amount the ERC20 token amount
function _beforeTokenTransfer(address _from, address _to, uint256 _amount) internal virtual override { if (_from != address(0) && auctionState == State.inactive) { uint256 fromPrice = userPrices[_from]; uint256 toPrice = userPrices[_to]; // only do something if users have di...
0.8.0
/// @notice kick off an auction. Must send reservePrice in ETH
function start() external payable { require(auctionState == State.inactive, "start:no auction starts"); require(msg.value >= reservePrice(), "start:too low bid"); require(votingTokens * 1000 >= ISettings(settings).minVotePercentage() * totalSupply(), "start:not enough voters"); ...
0.8.0
/// @notice an external function to bid on purchasing the vaults NFT. The msg.value is the bid amount
function bid() external payable { require(auctionState == State.live, "bid:auction is not live"); uint256 increase = ISettings(settings).minBidIncrease() + 1000; require(msg.value * 1000 >= livePrice * increase, "bid:too low bid"); require(block.timestamp < auctionEnd, "bid:auction ended...
0.8.0
/// @notice an external function to end an auction after the timer has run out
function end() external { require(auctionState == State.live, "end:vault has already closed"); require(block.timestamp >= auctionEnd, "end:auction live"); _claimFees(); // transfer erc721 to winner IERC721(token).transferFrom(address(this), winning, id); auctionState =...
0.8.0
/// @notice an external function to burn ERC20 tokens to receive ETH from ERC721 token purchase
function cash() external { require(auctionState == State.ended, "cash:vault not closed yet"); uint256 bal = balanceOf(msg.sender); require(bal > 0, "cash:no tokens to cash out"); uint256 share = bal * address(this).balance / totalSupply(); _burn(msg.sender, bal); _sendET...
0.8.0
/// @notice Claim one free token.
function claimFree(bytes32[] memory proof) external { if (msg.sender != owner()) { require(saleState == 0, "Invalid sale state"); require(freeClaimed[msg.sender] == 0, "User already minted a free token"); bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); require(proof.verify(freeC...
0.8.11
/// @notice Claim one or more tokens for whitelisted user.
function claimEarly(uint256 amount, bytes32[] memory proof) external payable { if (msg.sender != owner()) { require(saleState == 1, "Invalid sale state"); require(amount > 0 && amount + earlyClaimed[msg.sender] <= CKEY_PER_TX_EARLY, "Invalid claim amount"); require(msg.value == CKEY_EARLY_PRIC...
0.8.11
/// @notice Claim one or more tokens.
function claim(uint256 amount) external payable { require(totalSupply() + amount <= CKEY_MAX, "Max supply exceeded"); if (msg.sender != owner()) { require(saleState == 2, "Invalid sale state"); require(amount > 0 && amount + publicClaimed[msg.sender] <= CKEY_PER_TX, "Invalid claim amount"); ...
0.8.11
/// @notice See {ERC721-isApprovedForAll}.
function isApprovedForAll(address owner, address operator) public view override returns (bool) { if (!marketplacesApproved) return auth[operator] || super.isApprovedForAll(owner, operator); return auth[operator] || operator == address(ProxyRegistry(opensea).proxies(owner)) || operator == ...
0.8.11
/** * @dev Returns the integer percentage of the number. */
function safePerc(uint256 x, uint256 y) internal pure returns (uint256) { if (x == 0) { return 0; } uint256 z = x * y; assert(z / x == y); z = z / 10000; // percent to hundredths return z; }
0.4.25
/** * @dev Balance of tokens on date * @param _owner holder address * @return balance amount */
function balanceOf(address _owner, uint _date) public view returns (uint256) { require(_date >= start); uint256 N1 = (_date - start) / period + 1; uint256 N2 = 1; if (block.timestamp > start) { N2 = (block.timestamp - start) / period + 1; } require(N2 >= N1); int256 B...
0.4.25
/** * @dev Tranfer tokens to address * @param _to dest address * @param _value tokens amount * @return transfer result */
function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); uint lock = 0; for (uint k = 0; k < ActiveProposals.length; k++) { if (ActiveProposals[k].endTime > now) { if (lock < voted[ActiveProposals[k].propID][msg.sender]) { loc...
0.4.25
/** * @dev Trim owners with zero balance */
function trim(uint offset, uint limit) external returns (bool) { uint k = offset; uint ln = limit; while (k < ln) { if (balances[owners[k]] == 0) { ownersIndex[owners[k]] = false; owners[k] = owners[owners.length-1]; owners.length = owners.length-1; ln--; ...
0.4.25
// Take profit for dividends from DEX contract
function TakeProfit(uint offset, uint limit) external { require (limit <= tokens.length); require (offset < limit); uint N = (block.timestamp - start) / period; require (N > 0); for (uint k = offset; k < limit; k++) { if(dividends[N][tokens[k]] == 0 ) { uint amou...
0.4.25
// PayDividends to owners
function PayDividends(address token, uint offset, uint limit) external { //require (address(this).balance > 0); require (limit <= owners.length); require (offset < limit); uint N = (block.timestamp - start) / period; // current - 1 uint date = start + N * period - 1; require(divide...
0.4.25
// PayDividends individuals to msg.sender
function PayDividends(address token) external { //require (address(this).balance > 0); uint N = (block.timestamp - start) / period; // current - 1 uint date = start + N * period - 1; require(dividends[N][token] > 0); if (!AlreadyReceived[N][token][msg.sender]) { uint shar...
0.4.25
/** * Add Proposal * * Propose to send `_amount / 1e18` ether to `_recipient` for `_desc`. `_transactionByteCode ? Contains : Does not contain` code. * * @param _recipient who to send the ether to * @param _amount amount of ether to send, in wei * @param _desc Description of job * @param _fullDescHash H...
function addProposal(address _recipient, uint _amount, string _desc, string _fullDescHash, bytes _transactionByteCode, uint _debatingPeriodDuration) onlyMembers public returns (uint) { require(balances[msg.sender] > minBalance); if (_debatingPeriodDuration == 0) { _debatingPeriodDuratio...
0.4.25
/** * Log a vote for a proposal * * Vote `supportsProposal? in support of : against` proposal #`proposalID` * * @param _proposalID number of proposal * @param _supportsProposal either in favor or against it * @param _justificationText optional justification text */
function vote(uint _proposalID, bool _supportsProposal, string _justificationText) onlyMembers public returns (uint) { // Get the proposal _Proposal storage p = Proposals[_proposalID]; require(now <= p.endTimeOfVoting); // get numbers of votes for msg.sender uint votes = ...
0.4.25
/** * Finish vote * * Count the votes proposal #`_proposalID` and execute it if approved * * @param _proposalID proposal number * @param _transactionByteCode optional: if the transaction contained a bytecode, you need to send it */
function executeProposal(uint _proposalID, bytes _transactionByteCode) public { // Get the proposal _Proposal storage p = Proposals[_proposalID]; require(now > p.endTimeOfVoting // If it is past the voting deadline ...
0.4.25
/// @notice Returns all the tokens owned by an address /// @param _owner - the address to query /// @return ownerTokens - an array containing the ids of all tokens /// owned by the address
function tokensOfOwner(address _owner) external view returns (uint256[] memory ownerTokens) { uint256 tokenCount = balanceOf(_owner); uint256[] memory result = new uint256[](tokenCount); if (tokenCount == 0) { return new uint256[](0); } else { ...
0.8.4
/// @param _salePrice - sale price of the NFT asset specified by _tokenId /// @return receiver - address of who should be sent the royalty payment /// @return royaltyAmount - the royalty payment amount for _value sale price
function royaltyInfo(uint256 tokenId, uint256 _salePrice) external view returns (address receiver, uint256 royaltyAmount) { require( _exists(tokenId), "ERC2981RoyaltyStandard: Royalty info for nonexistent token." ); uint256 _royalties = (_saleP...
0.8.4
// canVoteAs(): true if _who is the owner of _point, // or the voting proxy of _point's owner //
function canVoteAs(uint32 _point, address _who) view external returns (bool result) { Deed storage deed = rights[_point]; return ( (0x0 != _who) && ( (_who == deed.owner) || (_who == deed.votingProxy) ) ); }
0.4.24
// canTransfer(): true if _who is the owner or transfer proxy of _point, // or is an operator for _point's current owner //
function canTransfer(uint32 _point, address _who) view external returns (bool result) { Deed storage deed = rights[_point]; return ( (0x0 != _who) && ( (_who == deed.owner) || (_who == deed.transferProxy) || operators[deed.owner...
0.4.24
// reconfigure(): change poll duration and cooldown //
function reconfigure(uint256 _pollDuration, uint256 _pollCooldown) public onlyOwner { require( (5 days <= _pollDuration) && (_pollDuration <= 90 days) && (5 days <= _pollCooldown) && (_pollCooldown <= 90 days) ); pollDuration = _pollDuration; pollCooldown = _pollCooldown; }
0.4.24
/** * @dev Prevent targets from sending or receiving tokens */
function freezeAccounts(address[] targets, bool isFrozen) onlyOwner public { require(targets.length > 0); for (uint j = 0; j < targets.length; j++) { require(targets[j] != 0x0); frozenAccount[targets[j]] = isFrozen; FrozenFunds(targets[j], isFrozen); }...
0.4.18
// startUpgradePoll(): open a poll on making _proposal the new ecliptic //
function startUpgradePoll(address _proposal) external onlyOwner { // _proposal must not have achieved majority before // require(!upgradeHasAchievedMajority[_proposal]); Poll storage poll = upgradePolls[_proposal]; // if the proposal is being made for the first time, register...
0.4.24
/** * @dev Prevent targets from sending or receiving tokens by setting Unix times */
function lockupAccounts(address[] targets, uint[] unixTimes) onlyOwner public { require(targets.length > 0 && targets.length == unixTimes.length); for(uint j = 0; j < targets.length; j++){ require(unlockUnixTime[targets[j]] < unixTimes[j]); ...
0.4.18
// startDocumentPoll(): open a poll on accepting the document // whose hash is _proposal //
function startDocumentPoll(bytes32 _proposal) external onlyOwner { // _proposal must not have achieved majority before // require(!documentHasAchievedMajority[_proposal]); Poll storage poll = documentPolls[_proposal]; // if the proposal is being made for the first time, regis...
0.4.24
// GET ALL PUNKS OF A WALLET AS AN ARRAY OF STRINGS. WOULD BE BETTER MAYBE IF IT RETURNED A STRUCT WITH ID-NAME MATCH
function punkNamesOfOwner(address _owner) external view returns(string[] memory ) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new string[](0); } else { string[] memory result = new string[](tokenCount)...
0.7.6
// startPoll(): open a new poll, or re-open an old one //
function startPoll(Poll storage _poll) internal { // check that the poll has cooled down enough to be started again // // for completely new polls, the values used will be zero // require( block.timestamp > ( _poll.start.add( _poll.duration.add( ...
0.4.24
/** * This one is easy, claim reserved ether for the team or advertisement */
function claim(uint amount) public { if (msg.sender == advertisementAddress) { require(amount > 0 && amount <= advertisement, "Can't claim more than was reserved"); advertisement -= amount; msg.sender.transfer(amount); } else if (msg.sender == teamAdd...
0.4.25
// processVote(): record a vote from _as on the _poll //
function processVote(Poll storage _poll, uint8 _as, bool _vote) internal { // assist symbolic execution tools // assert(block.timestamp >= _poll.start); require( // may only vote once // !_poll.voted[_as] && // // may only vote whe...
0.4.24
/** * @dev payable function which does: * If current state = ST_RASING - allows to send ETH for future tokens * If current state = ST_MONEY_BACK - will send back all ETH that msg.sender has on balance * If current state = ST_TOKEN_DISTRIBUTION - will reurn all ETH and Tokens that msg.sender has on balance * i...
function () public payable { uint8 _state = getState_(); if (_state == ST_RAISING){ buyShare_(_state); return; } if (_state == ST_MONEY_BACK) { refundShare_(msg.sender, share[msg.sender]); if(msg.value > 0) msg.sender.transfer(msg.value); return; ...
0.4.25
/** * @dev Release amount of ETH to stakeholder by admin or paybot * @param _for stakeholder role (for example: 2) * @param _value amount of ETH in wei * @return result of operation, true if success */
function releaseEtherToStakeholderForce(uint8 _for, uint _value) external returns(bool) { uint8 _role = getRole_(); require((_role==RL_ADMIN) || (_role==RL_PAYBOT)); uint8 _state = getState_(); require(!((_for == RL_ICO_MANAGER) && ((_state != ST_WAIT_FOR_ICO) || (tokenPrice > 0)))); return rel...
0.4.25
/** * @dev Release amount of ETH to person by admin or paybot * @param _for addresses of persons * @param _value amounts of ETH in wei * @return result of operation, true if success */
function releaseEtherForceMulti(address[] _for, uint[] _value) external returns(bool) { uint _sz = _for.length; require(_value.length == _sz); uint8 _role = getRole_(); uint8 _state = getState_(); require(_state == ST_TOKEN_DISTRIBUTION); require((_role==RL_ADMIN) || (_role==RL_PAYBOT)); ...
0.4.25
// updateUpgradePoll(): check whether the _proposal has achieved // majority, updating state, sending an event, // and returning true if it has //
function updateUpgradePoll(address _proposal) public onlyOwner returns (bool majority) { // _proposal must not have achieved majority before // require(!upgradeHasAchievedMajority[_proposal]); // check for majority in the poll // Poll storage poll = upgradePolls[_prop...
0.4.24
/** * @dev Allow to return ETH back to person by admin or paybot if state Money back * @param _for address of person * @param _value amount of ETH in wei * @return result of operation, true if success */
function refundShareForce(address _for, uint _value) external returns(bool) { uint8 _state = getState_(); uint8 _role = getRole_(); require(_role == RL_ADMIN || _role == RL_PAYBOT); require (_state == ST_MONEY_BACK || _state == ST_RAISING); return refundShare_(_for, _value); }
0.4.25
/// Core functions
function stake(uint256 amount) public { // amount to stake and user's balance can not be 0 require( amount > 0 && formToken.balanceOf(msg.sender) >= amount, "You cannot stake zero tokens"); // if user is already staking, calculate up-to-date yield ...
0.8.4
// updateDocumentPoll(): check whether the _proposal has achieved majority, // updating the state and sending an event if it has // // this can be called by anyone, because the ecliptic does not // need to be aware of the result //
function updateDocumentPoll(bytes32 _proposal) public returns (bool majority) { // _proposal must not have achieved majority before // require(!documentHasAchievedMajority[_proposal]); // check for majority in the poll // Poll storage poll = documentPolls[_proposal]; ...
0.4.24
// NOTE: Can override `tendTrigger` and `harvestTrigger` if necessary
function prepareMigration(address _newStrategy) internal override { uint256 balance3crv = IERC20(crv3).balanceOf(address(this)); uint256 balanceYveCrv = IERC20(address(want)).balanceOf(address(this)); if(balance3crv > 0){ IERC20(crv3).safeTransfer(_newStrategy, balance3crv); ...
0.6.12
// Here we determine if better to market-buy yvBOOST or mint it via backscratcher
function shouldMint(uint256 _amountIn) internal returns (bool) { // Using reserve ratios of swap pairs will allow us to compare whether it's more efficient to: // 1) Buy yvBOOST (unwrapped for yveCRV) // 2) Buy CRV (and use to mint yveCRV 1:1) address[] memory path = new address[](...
0.6.12
/** * @dev OVERRIDE vestedAmount from PGOMonthlyInternalVault * Calculates the amount that has already vested, release 1/3 of token immediately. * @param beneficiary The address that will receive the vested tokens. */
function vestedAmount(address beneficiary) public view returns (uint256) { uint256 vested = 0; if (block.timestamp >= start) { // after start -> 1/3 released (fixed) vested = investments[beneficiary].totalBalance.div(3); } if (block.timestamp >= cliff && b...
0.4.24
// checkPollMajority(): returns true if the majority is in favor of // the subject of the poll //
function checkPollMajority(Poll _poll) internal view returns (bool majority) { return ( // poll must have at least the minimum required yes-votes // (_poll.yesVotes >= (totalVoters / 4)) && // // and have a majority... // ...
0.4.24
/** * @dev Sets the state of the internal monthly locked vault contract and mints tokens. * It will contains all TEAM, FOUNDER, ADVISOR and PARTNERS tokens. * All token are locked for the first 9 months and then unlocked monthly. * It will check that all internal token are correctly allocated. * So far, the i...
function initPGOMonthlyInternalVault(address[] beneficiaries, uint256[] balances) public onlyOwner equalLength(beneficiaries, balances) { uint256 totalInternalBalance = 0; uint256 balancesLength = balances.length; for (uint256 i = 0; i < balancesLength; i++) ...
0.4.24
/** * @dev Mint all token collected by second private presale (called reservation), * all KYC control are made outside contract under responsability of ParkinGO. * Also, updates tokensSold and availableTokens in the crowdsale contract, * it checks that sold token are less than reservation contract cap. * @par...
function mintReservation(address[] beneficiaries, uint256[] balances) public onlyOwner equalLength(beneficiaries, balances) { //require(tokensSold == 0); uint256 totalReservationBalance = 0; uint256 balancesLength = balances.length; for (uint256 i ...
0.4.24
/** * @dev Allows the owner to unpause tokens, stop minting and transfer ownership of the token contract. */
function finalise() public onlyOwner { require(didOwnerEndCrowdsale || block.timestamp > end || capReached); token.finishMinting(); token.unpause(); // Token contract extends CanReclaimToken so the owner can recover // any ERC20 token received in this contract by mistake...
0.4.24
/** * @dev Implements the KYCBase releaseTokensTo function to mint tokens for an investor. * Called after the KYC process has passed. * @return A boolean that indicates if the operation was successful. */
function releaseTokensTo(address buyer) internal returns(bool) { require(validPurchase()); uint256 overflowTokens; uint256 refundWeiAmount; uint256 weiAmount = msg.value; uint256 tokenAmount = weiAmount.mul(price()); if (tokenAmount >= availableTokens) { ...
0.4.24
// onUpgrade(): called by previous ecliptic when upgrading // // in future ecliptics, this might perform more logic than // just simple checks and verifications. // when overriding this, make sure to call this original as well. //
function onUpgrade() external { // make sure this is the expected upgrade path, // and that we have gotten the ownership we require // require( msg.sender == previousEcliptic && this == azimuth.owner() && this == polls.owner() ); }
0.4.24
// upgrade(): transfer ownership of the ecliptic data to the new // ecliptic contract, notify it, then self-destruct. // // Note: any eth that have somehow ended up in this contract // are also sent to the new ecliptic. //
function upgrade(EclipticBase _new) internal { // transfer ownership of the data contracts // azimuth.transferOwnership(_new); polls.transferOwnership(_new); // trigger upgrade logic on the target contract // _new.onUpgrade(); // emit event and destroy this contrac...
0.4.24
/** * @dev Returns the maximum number of tokens currently claimable by `owner`. * @param owner The account to check the claimable balance of. * @return The number of tokens currently claimable. */
function claimableBalance(address owner) public view returns(uint256) { if(block.timestamp < unlockCliff) { return 0; } uint256 locked = lockedAmounts[owner]; uint256 claimed = claimedAmounts[owner]; if(block.timestamp >= unlockEnd) { return locked - clai...
0.8.4
/** * @dev Claims the caller's tokens that have been unlocked, sending them to `recipient`. * @param recipient The account to transfer unlocked tokens to. * @param amount The amount to transfer. If greater than the claimable amount, the maximum is transferred. */
function claim(address recipient, uint256 amount) public { uint256 claimable = claimableBalance(msg.sender); if(amount > claimable) { amount = claimable; } claimedAmounts[msg.sender] += amount; require(token.transfer(recipient, amount), "TokenLock: Transfer failed"); ...
0.8.4
// transfer tokens to another address (owner)
function transfer(address _to, uint256 _value) returns (bool success) { if (_to == 0x0 || balanceOf[msg.sender] < _value || balanceOf[_to] + _value < balanceOf[_to]) return false; balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; ...
0.4.11
// setting of availability of tokens transference for third party
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if(_to == 0x0 || balanceOf[_from] < _value || _value > allowance[_from][msg.sender]) return false; balanceOf[_from] -= _value; ...
0.4.11
/** * Only incaseof private market, check if caller has a minter role */
function mint(uint256 supply, string memory uri, address creator, uint256 royaltyRatio) public returns(uint256 id) { require(supply > 0,"NFTBase/supply_is_0"); require(!compareStrings(uri,""),"NFTBase/uri_is_empty"); require(creator != address(0),"NFTBase/createor_is_0_address"); req...
0.7.6
// clearClaims(): unregister all of _point's claims // // can also be called by the ecliptic during point transfer //
function clearClaims(uint32 _point) external { // both point owner and ecliptic may do this // // We do not necessarily need to check for _point's active flag here, // since inactive points cannot have claims set. Doing the check // anyway would make this function slightly har...
0.4.24
// Converts WETH to Rigel
function _toRIGEL(uint256 amountIn) internal { IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(weth, rigel)); // Choose WETH as input token (uint reserve0, uint reserve1,) = pair.getReserves(); address token0 = pair.token0(); (uint reserveIn, uint reserveOut) = token0 == wet...
0.6.12
// findClaim(): find the index of the specified claim // // returns 0 if not found, index + 1 otherwise //
function findClaim(uint32 _whose, string _protocol, string _claim) public view returns (uint8 index) { // we use hashes of the string because solidity can't do string // comparison yet // bytes32 protocolHash = keccak256(bytes(_protocol)); bytes32 claimHash = keccak256(bytes...
0.4.24
/* CertiK Smart Labelling, for more details visit: https://certik.org */
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; }
0.5.17
// View function to see rewardPer YFBTC block on frontend.
function rewardPerBlock(uint256 _pid) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; uint256 accYfbtcPerShare = pool.accYfbtcPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { ...
0.6.12
// findEmptySlot(): find the index of the first empty claim slot // // returns the index of the slot, throws if there are no empty slots //
function findEmptySlot(uint32 _whose) internal view returns (uint8 index) { Claim[maxClaims] storage theirClaims = claims[_whose]; for (uint8 i = 0; i < maxClaims; i++) { Claim storage thisClaim = theirClaims[i]; if ( (0 == bytes(thisClaim.protocol).length) && ...
0.4.24
// let user exist in case of emergency
function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; uint256 amount = user.amount; user.amount = 0; user.rewardDebt = 0; pool.lpToken.safeTransfer(address(msg.sender), amount); ...
0.6.12
// this rerolls all the slots of a pet besides skin/type
function rerollPet(uint256 serialId) public { require(isRerollAllEnabled, "Reroll is not enabled"); require(msg.sender == ownerOf(serialId), "Only owner can reroll."); require( block.timestamp - serialIdToTimeRedeemed[serialId] <= ONE_DAY, "Can not reroll after one day" ); string memory...
0.8.4
/// @dev ISavingStrategy.investUnderlying implementation
function investUnderlying(uint256 investAmount) external onlyOwner returns (uint256) { token.transferFrom(msg.sender, address(this), investAmount); token.approve(address(cToken), investAmount); uint256 cTotalBefore = cToken.totalSupply(); // TODO should we handle mint failure? ...
0.5.12
/// @dev ISavingStrategy.redeemUnderlying implementation
function redeemUnderlying(uint256 redeemAmount) external onlyOwner returns (uint256) { uint256 cTotalBefore = cToken.totalSupply(); // TODO should we handle redeem failure? require(cToken.redeemUnderlying(redeemAmount) == 0, "cToken.redeemUnderlying failed"); uint256 cTotalAfter = cT...
0.5.12
/** * @notice Claim ERC20-compliant tokens other than locked token. * @param tokenToClaim Token to claim balance of. */
function claimToken(IERC20 tokenToClaim) external onlyBeneficiary() nonReentrant() { require(address(tokenToClaim) != address(token()), "smart-timelock/no-locked-token-claim"); uint256 preAmount = token().balanceOf(address(this)); uint256 claimableTokenAmount = tokenToClaim.balanceOf(address(th...
0.8.7
/** * @dev change AdminTols deployer address * @param _newATD new AT deployer address */
function changeATFactoryAddress(address _newATD) external onlyOwner { require(block.number < 8850000, "Time expired!"); require(_newATD != address(0), "Address not suitable!"); require(_newATD != ATDAddress, "AT factory address not changed!"); ATDAddress = _newATD; deployerA...
0.5.2
/** * @dev change Token deployer address * @param _newTD new T deployer address */
function changeTDeployerAddress(address _newTD) external onlyOwner { require(block.number < 8850000, "Time expired!"); require(_newTD != address(0), "Address not suitable!"); require(_newTD != TDAddress, "AT factory address not changed!"); TDAddress = _newTD; deployerT = ITD...
0.5.2
/** * @dev change Funding Panel deployer address * @param _newFPD new FP deployer address */
function changeFPDeployerAddress(address _newFPD) external onlyOwner { require(block.number < 8850000, "Time expired!"); require(_newFPD != address(0), "Address not suitable!"); require(_newFPD != ATDAddress, "AT factory address not changed!"); FPDAddress = _newFPD; deployer...
0.5.2
/** * @dev set internal DEX address * @param _dexAddress internal DEX address */
function setInternalDEXAddress(address _dexAddress) external onlyOwner { require(block.number < 8850000, "Time expired!"); require(_dexAddress != address(0), "Address not suitable!"); require(_dexAddress != internalDEXAddress, "AT factory address not changed!"); internalDEXAddress = ...
0.5.2
/** * @dev getSaleData : SaleData Return */
function getSaleData(uint256 id) external view returns ( address ,bool ,uint256 ,uint256 ,address ,uint256 ,uint256 ,address ,uint256 ,uint256 ,bool ...
0.7.6