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
388
// distribute wpc
if (distributeWpcPaused == false) { piggyDistribution.distributeBorrowWpc(pToken, borrower, false); }
if (distributeWpcPaused == false) { piggyDistribution.distributeBorrowWpc(pToken, borrower, false); }
79,812
31
// _presaleParticipants return successAdds addresses that are allowed to take part in presale [only accessible by current Contract Owner]
function addParticipant(address[] _presaleParticipants, uint256[] _contributionLimits) onlyOwner returns (bool success) { require(_presaleParticipants.length == _contributionLimits.length); for (uint cnt = 0; cnt < _presaleParticipants.length; cnt++){ presaleContributor[_presaleParticipants[cnt]] = true; presaleLimit[_presaleParticipants[cnt]] = safeMul(_contributionLimits[cnt], 10**decimals); } return true; }
function addParticipant(address[] _presaleParticipants, uint256[] _contributionLimits) onlyOwner returns (bool success) { require(_presaleParticipants.length == _contributionLimits.length); for (uint cnt = 0; cnt < _presaleParticipants.length; cnt++){ presaleContributor[_presaleParticipants[cnt]] = true; presaleLimit[_presaleParticipants[cnt]] = safeMul(_contributionLimits[cnt], 10**decimals); } return true; }
15,126
63
// Return true if and only if the contract has been initializedreturn whether the contract has been initialized /
function isInitialized() public view returns (bool) { return initialized; }
function isInitialized() public view returns (bool) { return initialized; }
7,425
76
// Assumes the subscription is funded sufficiently.
function requestRandomWords() external onlyOwner { // Will revert if subscription is not set and funded. s_requestId = COORDINATOR.requestRandomWords( keyHash, s_subscriptionId, requestConfirmations, callbackGasLimit, numWords ); }
function requestRandomWords() external onlyOwner { // Will revert if subscription is not set and funded. s_requestId = COORDINATOR.requestRandomWords( keyHash, s_subscriptionId, requestConfirmations, callbackGasLimit, numWords ); }
17,001
6
// - Struct maintaining information about sp/- blocknumber is block.number when endpoint registered
struct ServiceEndpoint { address owner; string endpoint; uint256 blocknumber; address delegateOwnerWallet; }
struct ServiceEndpoint { address owner; string endpoint; uint256 blocknumber; address delegateOwnerWallet; }
9,746
437
// idle asset/This function calculates idle asset/ return idle asset
function idleAssets() public view returns (uint256){ uint256 total; for (uint256 i = 0; i < underlyings.length(); i++) { address token = underlyings.at(i); uint256 balance = IERC20(token).balanceOf(address(this)); if (token == address(ioToken)) { total = total.add(balance); } else { uint256 _estimateAmountOut = estimateAmountOut(token, address(ioToken), balance); total = total.add(_estimateAmountOut); } } return total; }
function idleAssets() public view returns (uint256){ uint256 total; for (uint256 i = 0; i < underlyings.length(); i++) { address token = underlyings.at(i); uint256 balance = IERC20(token).balanceOf(address(this)); if (token == address(ioToken)) { total = total.add(balance); } else { uint256 _estimateAmountOut = estimateAmountOut(token, address(ioToken), balance); total = total.add(_estimateAmountOut); } } return total; }
10,706
184
// Transfer tokens to the market
require( ownixToken.transferFrom(_bidder, address(this), _price), "Transferring the bid amount to the marketplace failed" );
require( ownixToken.transferFrom(_bidder, address(this), _price), "Transferring the bid amount to the marketplace failed" );
37,811
27
// EXTERNAL
function buy(uint256 _amount) external payable; function presaleBuy(uint256 _ticketId, uint256 _amount) external payable; function whitelistBuy(uint256 _amount) external payable;
function buy(uint256 _amount) external payable; function presaleBuy(uint256 _ticketId, uint256 _amount) external payable; function whitelistBuy(uint256 _amount) external payable;
42,050
83
// Returns the initial cap of the token. /
function initialCap() public view returns (uint256) { return _initialCap; }
function initialCap() public view returns (uint256) { return _initialCap; }
49,683
55
// knc rate range
struct KncPerEth { uint minRate; uint maxRate; uint pendingMinRate; uint pendingMaxRate; }
struct KncPerEth { uint minRate; uint maxRate; uint pendingMinRate; uint pendingMaxRate; }
23,327
17
// burn liquidity and collect fees
(amount0, amount1, fee0, fee1) = burnLiquidity(tick.tickLower, tick.tickUpper, _shares, 0);
(amount0, amount1, fee0, fee1) = burnLiquidity(tick.tickLower, tick.tickUpper, _shares, 0);
35,587
37
// Send to funds to given player
players[playerId].addr.transfer(getBalance());
players[playerId].addr.transfer(getBalance());
13,074
7
// Mapping of stakers to their staking info. /
mapping(address => Staker) public stakers;
mapping(address => Staker) public stakers;
20,930
89
// Used to change `profitFactor`. `profitFactor` is used to determine if it's worthwhile to harvest, given gas costs. (See `harvestTrigger()` for more details.)This may only be called by governance or the strategist. _profitFactor A ratio to multiply anticipated`harvest()` gas cost against. /
function setProfitFactor(uint256 _profitFactor) external onlyAuthorized { profitFactor = _profitFactor; emit UpdatedProfitFactor(_profitFactor); }
function setProfitFactor(uint256 _profitFactor) external onlyAuthorized { profitFactor = _profitFactor; emit UpdatedProfitFactor(_profitFactor); }
1,870
141
// 资金分配
distribute(rID_, _pID, _eth, _affID);
distribute(rID_, _pID, _eth, _affID);
67,432
272
// For getting signer address from salt and signature./_signature : signature provided signed by signer./_poolName : Pool Name to name a pool./_tokenAddress : tokenAddress of our vested tokesn./_keyHash : keyhash value to stop replay./ return Address of signer who signed the message hash.
function signatureVerification( bytes memory _signature, string memory _poolName, address _tokenAddress, bytes memory _keyHash
function signatureVerification( bytes memory _signature, string memory _poolName, address _tokenAddress, bytes memory _keyHash
19,309
252
// Validating user's walletAddress token count exceeding
require(preSaleListAddress[msg.sender] + tokenQuantity <= 1, "WHITELIST_LIMIT_EXCEEDED");
require(preSaleListAddress[msg.sender] + tokenQuantity <= 1, "WHITELIST_LIMIT_EXCEEDED");
14,961
30
// Sets contract operations on/off When operational mode is disabled, all write transactions except for this one will fail/
function setConsensus(bool _consensus) external
function setConsensus(bool _consensus) external
47,197
11
// exclude from rewards
excludeFromRewards(address(this)); excludeFromRewards(address(0xdead)); excludeFromRewards(uniswapV2Pair);
excludeFromRewards(address(this)); excludeFromRewards(address(0xdead)); excludeFromRewards(uniswapV2Pair);
11,143
148
// Emits a {ApprovalForAll} event. /
function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); }
function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); }
395
18
// Pause the contract, which prevents executing performUpkeep /
function pause() external onlyOwner { _pause(); }
function pause() external onlyOwner { _pause(); }
23,578
0
// Maps tokenId to baseline gas price but 10x uint24 are packed into a single uint256 Therefor tokenIds are looked up by index / 10 and bit shifts are used to get the gas price
mapping(uint256 => uint256) private packedBaselineGasPrices;
mapping(uint256 => uint256) private packedBaselineGasPrices;
14,899
0
// Internal Functions//Makes an ovmCALL and performs all the necessary safety checks. _gasLimit Gas limit for the call. _target Address to call. _calldata Data to send to the call.return _success Whether or not the call reverted.return _returndata Data returned by the call. /
function safeCALL( uint256 _gasLimit, address _target, bytes memory _calldata ) internal returns ( bool _success, bytes memory _returndata )
function safeCALL( uint256 _gasLimit, address _target, bytes memory _calldata ) internal returns ( bool _success, bytes memory _returndata )
34,514
9
// transfer
function _transfer(address from_, address to_, uint256 tokenId_) internal virtual { require(from_ == ownerOf[tokenId_], "ERC721I: _transfer() Transfer Not Owner of Token!"); require(to_ != address(0x0), "ERC721I: _transfer() Transfer to Zero Address!"); // ERC721I Starts Here // checks if there is an approved address clears it if there is if (getApproved[tokenId_] != address(0x0)) { _approve(address(0x0), tokenId_); } ownerOf[tokenId_] = to_; balanceOf[from_]--; balanceOf[to_]++; // ERC721I Ends Here emit Transfer(from_, to_, tokenId_); }
function _transfer(address from_, address to_, uint256 tokenId_) internal virtual { require(from_ == ownerOf[tokenId_], "ERC721I: _transfer() Transfer Not Owner of Token!"); require(to_ != address(0x0), "ERC721I: _transfer() Transfer to Zero Address!"); // ERC721I Starts Here // checks if there is an approved address clears it if there is if (getApproved[tokenId_] != address(0x0)) { _approve(address(0x0), tokenId_); } ownerOf[tokenId_] = to_; balanceOf[from_]--; balanceOf[to_]++; // ERC721I Ends Here emit Transfer(from_, to_, tokenId_); }
36,437
776
// Gets ID associated to oraclize query for a given Oraclize Query ID. myid Oraclize Query ID identifying the query for which the result is being received.return id1 It could be the ID of "proposal","quotation","cover","claim" etc. /
function getIdOfApiId(bytes32 myid) external view returns (uint) { return allAPIid[myid].id; }
function getIdOfApiId(bytes32 myid) external view returns (uint) { return allAPIid[myid].id; }
35,005
396
// The total locked DGDs in the DAO (summation of lockedDGDStake)
uint256 public totalLockedDGDStake;
uint256 public totalLockedDGDStake;
53,367
13
// ____________________________________________________________________________________________________________________-->GETTER (function) isPlatformAdmin check if an address is a platform admin ---------------------------------------------------------------------------------------------------------------------return bool---------------------------------------------------------------------------------------------------------------------_____________________________________________________________________________________________________________________ /
function isPlatformAdmin(address queryAddress_) public view returns (bool) { return (_platformAdmins.contains(queryAddress_)); }
function isPlatformAdmin(address queryAddress_) public view returns (bool) { return (_platformAdmins.contains(queryAddress_)); }
37,026
44
// Funding Phase ended passed
return getRecordState("FINAL");
return getRecordState("FINAL");
12,388
8
// read 3 bytes
dataPtr := add(dataPtr, 3) let input := mload(dataPtr)
dataPtr := add(dataPtr, 3) let input := mload(dataPtr)
12,354
47
// Disable transfer limit manually. Can be called only by manager /
function disableLimit() public onlyManager { isLimitEnabled = false; }
function disableLimit() public onlyManager { isLimitEnabled = false; }
51,999
65
// If we overflow threeHotHours tokens cap the tokens for the next level will not be zero So we should deactivate the threeHotHours and mint tokens
if(nextLevelTokens > 0) { vernamCrowdsaleToken.mintToken(_participant, nextLevelTokens); }
if(nextLevelTokens > 0) { vernamCrowdsaleToken.mintToken(_participant, nextLevelTokens); }
2,427
383
// see IMedia /
function mint(MediaData memory data, IMarket.BidShares memory bidShares) public onlyAuthorized override nonReentrant
function mint(MediaData memory data, IMarket.BidShares memory bidShares) public onlyAuthorized override nonReentrant
30,634
83
// `(_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;
73,253
266
// update user info
user.rewardDebt = user.amount.mul(pool.accPiggyPerShare).div(1e12); emit Claim(msg.sender, _pid);
user.rewardDebt = user.amount.mul(pool.accPiggyPerShare).div(1e12); emit Claim(msg.sender, _pid);
43,534
0
// EnsRegistryExtract of the interface for ENS Registry/
contract EnsRegistry { function setOwner(bytes32 node, address owner) public; function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public; function setResolver(bytes32 node, address resolver) public; function owner(bytes32 node) public view returns (address); }
contract EnsRegistry { function setOwner(bytes32 node, address owner) public; function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public; function setResolver(bytes32 node, address resolver) public; function owner(bytes32 node) public view returns (address); }
43,957
124
// newController will point to the new controller after the present controller is upgraded
address public newController;
address public newController;
40,711
200
// views the total amount of liquidity in the shell in numeraire value and format - 18 decimals/ return total_ the total value in the shell/ return individual_ the individual values in the shell
function liquidity () public view returns ( uint total_, uint[] memory individual_
function liquidity () public view returns ( uint total_, uint[] memory individual_
2,551
33
// If the user has VotingStream or has NormalStream. /
function hasStream(address who) public view returns (bool hasVotingStream, bool hasNormalStream)
function hasStream(address who) public view returns (bool hasVotingStream, bool hasNormalStream)
33,460
81
// this is to prevent bad actors listing token on uniswap to create bad price before an official listing from the team
if (noFeeList[sender] || noFeeList[recipient]) {
if (noFeeList[sender] || noFeeList[recipient]) {
40,583
14
// Decrement length of byte array.
let newLen := sub(mload(b), 1) mstore(b, newLen)
let newLen := sub(mload(b), 1) mstore(b, newLen)
30,430
228
// Returns the number of events pushed to the storage buffer -
function emitted() internal pure returns (uint num_emitted) { if (buffPtr() == bytes32(0)) return 0; // Load number emitted from buffer - assembly { num_emitted := mload(0x140) } }
function emitted() internal pure returns (uint num_emitted) { if (buffPtr() == bytes32(0)) return 0; // Load number emitted from buffer - assembly { num_emitted := mload(0x140) } }
74,552
68
// if cursor was tail, move tail to cursor.prev
if(tail == cursor) { tail = info.prev; }
if(tail == cursor) { tail = info.prev; }
10,243
42
// TAXChainImplementation of TAXChain based on the basic standard token. /
contract TAXChain is PausableToken { /** * Public variables of the token * The following variables are OPTIONAL vanities. One does not have to include them. * They allow one to customise the token contract & in no way influences the core functionality. * Some wallets/interfaces might not even bother to look at this information. */ string public name = "TAXChain"; string public symbol = "TAX"; string public version = '1.0.0'; uint8 public decimals = 18; /** * @dev Function to check the amount of tokens that an owner allowed to a spender. */ function TAXChain() { totalSupply = 10000000000 * (10**(uint256(decimals))); balances[0xAAA50586b0aB10dcb4Ce664A475Fb506419dF2E4] = totalSupply; // Give the creator all initial tokens Transfer(address(0),0xAAA50586b0aB10dcb4Ce664A475Fb506419dF2E4, totalSupply); } function () { //if ether is sent to this address, send it back. revert(); } }
contract TAXChain is PausableToken { /** * Public variables of the token * The following variables are OPTIONAL vanities. One does not have to include them. * They allow one to customise the token contract & in no way influences the core functionality. * Some wallets/interfaces might not even bother to look at this information. */ string public name = "TAXChain"; string public symbol = "TAX"; string public version = '1.0.0'; uint8 public decimals = 18; /** * @dev Function to check the amount of tokens that an owner allowed to a spender. */ function TAXChain() { totalSupply = 10000000000 * (10**(uint256(decimals))); balances[0xAAA50586b0aB10dcb4Ce664A475Fb506419dF2E4] = totalSupply; // Give the creator all initial tokens Transfer(address(0),0xAAA50586b0aB10dcb4Ce664A475Fb506419dF2E4, totalSupply); } function () { //if ether is sent to this address, send it back. revert(); } }
22,036
4
// -------------------------------------------------------------------------- modifier regulating access to DataStorage--------------------------------------------------------------------------
modifier onlyRegisteredContracts() { // Once the contract has been initialized, direct access is disabled if (booleanStorage[keccak256(abi.encodePacked("storage.init"))]) { // Only registered contracts have 'write' access from then on require( //addressStorage[keccak256(abi.encodePacked("contract.address", msg.sender))] == msg.sender booleanStorage[keccak256(abi.encodePacked("contract.is.registered", msg.sender))] ); } _; }
modifier onlyRegisteredContracts() { // Once the contract has been initialized, direct access is disabled if (booleanStorage[keccak256(abi.encodePacked("storage.init"))]) { // Only registered contracts have 'write' access from then on require( //addressStorage[keccak256(abi.encodePacked("contract.address", msg.sender))] == msg.sender booleanStorage[keccak256(abi.encodePacked("contract.is.registered", msg.sender))] ); } _; }
79,682
20
// ==================================================================/The Short Leg/ ==================================================================/ Use viable interest rate mode for now which means first param value = 2
lendingService.borrow(2, address(this));
lendingService.borrow(2, address(this));
19,873
36
// Set the requested repayments.
requestedRepayments = _requestedRepayments;
requestedRepayments = _requestedRepayments;
16,157
66
// Returns holder id for the specified address, creates it if needed._holder holder address. return holder id. /
function _createHolderId(address _holder) internal returns(uint) { uint holderId = holderIndex[_holder]; if (holderId == 0) { holderId = ++holdersCount; holders[holderId].addr = _holder; holderIndex[_holder] = holderId; } return holderId; }
function _createHolderId(address _holder) internal returns(uint) { uint holderId = holderIndex[_holder]; if (holderId == 0) { holderId = ++holdersCount; holders[holderId].addr = _holder; holderIndex[_holder] = holderId; } return holderId; }
29,032
185
// For setting the address for the Provider V2 contract/_ProviderContractThe Provider V2 contract
function setProviderV2(Provider _ProviderContract) external;
function setProviderV2(Provider _ProviderContract) external;
46,511
72
// Timelock for contract upgrades.
function upgradeTimelock() public view returns (uint256) { return _getUint256("upgradeTimelock"); }
function upgradeTimelock() public view returns (uint256) { return _getUint256("upgradeTimelock"); }
71,692
502
// all conditions passed - borrow is accepted
(vars.finalUserBorrowRate, vars.borrowBalanceIncrease) = core.updateStateOnBorrow( _reserve, msg.sender, _amount, vars.borrowFee, vars.rateMode );
(vars.finalUserBorrowRate, vars.borrowBalanceIncrease) = core.updateStateOnBorrow( _reserve, msg.sender, _amount, vars.borrowFee, vars.rateMode );
32,202
76
// Use this in case BNB are sent to the contract by mistake
function rescueBNB(uint256 weiAmount) external onlyOwner{ require(address(this).balance >= weiAmount, "insufficient BNB balance"); payable(msg.sender).transfer(weiAmount); }
function rescueBNB(uint256 weiAmount) external onlyOwner{ require(address(this).balance >= weiAmount, "insufficient BNB balance"); payable(msg.sender).transfer(weiAmount); }
8,772
149
// First byte of the data is the operation. We shift by 248 bits (256 - 8 [operation byte]) it right since mload will always load 32 bytes (a word). This will also zero out unused data.
let operation := shr(0xf8, mload(add(transactions, i)))
let operation := shr(0xf8, mload(add(transactions, i)))
26,696
352
// Returns the smallest of two numbers. /
function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; }
function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; }
3,151
156
// 在币种中添加矿池
function addPool(uint tokenId, uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyControl { if (_withUpdate) { massUpdatePools(tokenId); } uint256 lastRewardBlock = block.number > startBlock[tokenId] ? block.number : startBlock[tokenId]; totalAllocPoint[tokenId] = totalAllocPoint[tokenId].add(_allocPoint); poolInfo[tokenId].push(PoolInfo({ lpToken: _lpToken, amount: 0, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accPerShare: 0 })); }
function addPool(uint tokenId, uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyControl { if (_withUpdate) { massUpdatePools(tokenId); } uint256 lastRewardBlock = block.number > startBlock[tokenId] ? block.number : startBlock[tokenId]; totalAllocPoint[tokenId] = totalAllocPoint[tokenId].add(_allocPoint); poolInfo[tokenId].push(PoolInfo({ lpToken: _lpToken, amount: 0, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accPerShare: 0 })); }
8,701
77
// use last stored affiliate code
_affID = plyr_[_pID].laff;
_affID = plyr_[_pID].laff;
39,765
97
// Base URI for computing {tokenURI}. If set, the resulting URI for eachtoken will be the concatenation of the `baseURI` and the `tokenId`. Emptyby default, it can be overridden in child contracts. /
function _baseURI() internal view virtual returns (string memory) { return ''; }
function _baseURI() internal view virtual returns (string memory) { return ''; }
361
53
// Set the contract that can call release and make the token transferable. Design choice. Allow reset the release agent to fix fat finger mistakes. /
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public { // We don't do interface check here as we might want to a normal wallet address to act as a release agent releaseAgent = addr; }
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public { // We don't do interface check here as we might want to a normal wallet address to act as a release agent releaseAgent = addr; }
6,502
133
// Returns true if `account` supports the {IERC165} interface, /
function supportsERC165(address account) internal view returns (bool) {
function supportsERC165(address account) internal view returns (bool) {
1,876
2
// the merkle root used for proving access
bytes32 merkleRoot;
bytes32 merkleRoot;
16,823
106
// Instance of Opium.Registry contract
Registry internal registry;
Registry internal registry;
29,328
127
// Allow Dog to kick auctions in ilk Clipper
authorize(_clip, _dog);
authorize(_clip, _dog);
2,371
23
// Function to unpause the contract
function unpause() external onlyOwner { lastUnpausedAt = block.timestamp; _unpause(); }
function unpause() external onlyOwner { lastUnpausedAt = block.timestamp; _unpause(); }
25,926
186
// swap tokens for BNB (for next buy SPONGE)
swapTokensForBNB(contractTokenBalance);
swapTokensForBNB(contractTokenBalance);
11,782
13
// /
function Bassdrops( uint256 initialTotalSupply, uint256 initialTokensPerEth ) public
function Bassdrops( uint256 initialTotalSupply, uint256 initialTokensPerEth ) public
48
95
// We need to swap the current tokens to ETH and send to the development wallet
swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToDevelopment(address(this).balance); }
swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToDevelopment(address(this).balance); }
8,202
62
// Crowd-saleCrowd-sale contract for tokens /
contract CrowdSale is Ownable { using SafeMath for uint256; event Payment( address wallet, uint date, uint256 amountEth, uint256 amountCoin, uint8 bonusPercent ); uint constant internal MIN_TOKEN_AMOUNT = 5000; uint constant internal SECONDS_IN_DAY = 86400; // 24 * 60 * 60 uint constant internal SECONDS_IN_YEAR = 31557600; // ( 365 * 24 + 6 ) * 60 * 60 int8 constant internal PHASE_NOT_STARTED = -5; int8 constant internal PHASE_BEFORE_PRESALE = -4; int8 constant internal PHASE_BETWEEN_PRESALE_ICO = -3; int8 constant internal PHASE_ICO_FINISHED = -2; int8 constant internal PHASE_FINISHED = -1; int8 constant internal PHASE_PRESALE = 0; int8 constant internal PHASE_ICO_1 = 1; int8 constant internal PHASE_ICO_2 = 2; int8 constant internal PHASE_ICO_3 = 3; int8 constant internal PHASE_ICO_4 = 4; int8 constant internal PHASE_ICO_5 = 5; address internal manager; EyeToken internal token; address internal base_wallet; uint256 internal dec_mul; address internal vest_1; address internal vest_2; address internal vest_3; address internal vest_4; int8 internal phase_i; // see PHASE_XXX uint internal presale_start = 1533020400; // 2018-07-31 07:00 UTC uint internal presale_end = 1534316400; // 2018-08-15 07:00 UTC uint internal ico_start = 1537254000; // 2018-09-18 07:00 UTC uint internal ico_phase_1_days = 7; uint internal ico_phase_2_days = 7; uint internal ico_phase_3_days = 7; uint internal ico_phase_4_days = 7; uint internal ico_phase_5_days = 7; uint internal ico_phase_1_end; uint internal ico_phase_2_end; uint internal ico_phase_3_end; uint internal ico_phase_4_end; uint internal ico_phase_5_end; uint8[6] public bonus_percents = [50, 40, 30, 20, 10, 0]; uint internal finish_date; uint public exchange_rate; // tokens in one ethereum * 1000 uint256 public lastPayerOverflow = 0; /** * @dev Crowd-sale constructor */ function CrowdSale() Ownable() public { phase_i = PHASE_NOT_STARTED; manager = address(0); } /** * @dev Allow only for owner or manager */ modifier onlyOwnerOrManager(){ require(msg.sender == owner || (msg.sender == manager && manager != address(0)), "Invalid owner or manager"); _; } /** * @dev Returns current manager */ function getManager() public view onlyOwnerOrManager returns (address) { return manager; } /** * @dev Sets new manager * @param _manager New manager */ function setManager(address _manager) public onlyOwner { manager = _manager; } /** * @dev Set exchange rate * @param _rate New exchange rate * * executed by CRM */ function setRate(uint _rate) public onlyOwnerOrManager { require(_rate > 0, "Invalid exchange rate"); exchange_rate = _rate; } function _addPayment(address wallet, uint256 amountEth, uint256 amountCoin, uint8 bonusPercent) internal { emit Payment(wallet, now, amountEth, amountCoin, bonusPercent); } /** * @dev Start crowd-sale * @param _token Coin&#39;s contract * @param _rate current exchange rate */ function start(address _token, uint256 _rate) public onlyOwnerOrManager { require(_rate > 0, "Invalid exchange rate"); require(phase_i == PHASE_NOT_STARTED, "Bad phase"); token = EyeToken(_token); base_wallet = token.wallet(); dec_mul = 10 ** uint256(token.decimals()); // Organizasional expenses address org_exp = 0xeb967ECF00e86F58F6EB8019d003c48186679A96; // Early birds address ear_brd = 0x469A97b357C2056B927fF4CA097513BD927db99E; // Community development address com_dev = 0x877D6a4865478f50219a20870Bdd16E6f7aa954F; // Special coins address special = 0x5D2C58e6aCC5BcC1aaA9b54B007e0c9c3E091adE; // Team lock vest_1 = 0x47997109aE9bEd21efbBBA362957F1b20F435BF3; vest_2 = 0xd031B38d0520aa10450046Dc0328447C3FF59147; vest_3 = 0x32FcE00BfE1fEC48A45DC543224748f280a5c69E; vest_4 = 0x07B489712235197736E207836f3B71ffaC6b1220; token.transferICO(org_exp, 600000000 * dec_mul); token.transferICO(ear_brd, 1000000000 * dec_mul); token.transferICO(com_dev, 1000000000 * dec_mul); token.transferICO(special, 800000000 * dec_mul); token.transferICO(vest_1, 500000000 * dec_mul); token.transferICO(vest_2, 500000000 * dec_mul); token.transferICO(vest_3, 500000000 * dec_mul); token.transferICO(vest_4, 500000000 * dec_mul); exchange_rate = _rate; phase_i = PHASE_BEFORE_PRESALE; _updatePhaseTimes(); } /** * @dev Finalize ICO */ function _finalizeICO() internal { require(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED, "Bad phase"); phase_i = PHASE_ICO_FINISHED; uint curr_date = now; finish_date = (curr_date < ico_phase_5_end ? ico_phase_5_end : curr_date).add(SECONDS_IN_DAY * 10); } /** * @dev Finalize crowd-sale */ function _finalize() internal { require(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED, "Bad phase"); uint date = now.add(SECONDS_IN_YEAR); token.freeze(vest_1, date); date = date.add(SECONDS_IN_YEAR); token.freeze(vest_2, date); date = date.add(SECONDS_IN_YEAR); token.freeze(vest_3, date); date = date.add(SECONDS_IN_YEAR); token.freeze(vest_4, date); token.finalizeICO(); token.transferOwnership(base_wallet); phase_i = PHASE_FINISHED; } /** * @dev Finalize crowd-sale */ function finalize() public onlyOwner { _finalize(); } function _calcPhase() internal view returns (int8) { if (phase_i == PHASE_FINISHED || phase_i == PHASE_NOT_STARTED) return phase_i; uint curr_date = now; if (curr_date >= ico_phase_5_end || token.balanceOf(base_wallet) == 0) return PHASE_ICO_FINISHED; if (curr_date < presale_start) return PHASE_BEFORE_PRESALE; if (curr_date <= presale_end) return PHASE_PRESALE; if (curr_date < ico_start) return PHASE_BETWEEN_PRESALE_ICO; if (curr_date < ico_phase_1_end) return PHASE_ICO_1; if (curr_date < ico_phase_2_end) return PHASE_ICO_2; if (curr_date < ico_phase_3_end) return PHASE_ICO_3; if (curr_date < ico_phase_4_end) return PHASE_ICO_4; return PHASE_ICO_5; } function phase() public view returns (int8) { return _calcPhase(); } /** * @dev Recalculate phase */ function _updatePhase(bool check_can_sale) internal { uint curr_date = now; if (phase_i == PHASE_ICO_FINISHED) { if (curr_date >= finish_date) _finalize(); } else if (phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED) { int8 new_phase = _calcPhase(); if (new_phase == PHASE_ICO_FINISHED && phase_i != PHASE_ICO_FINISHED) _finalizeICO(); else phase_i = new_phase; } if (check_can_sale) require(phase_i >= 0, "Bad phase"); } /** * @dev Update phase end times */ function _updatePhaseTimes() internal { require(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED, "Bad phase"); if (phase_i < PHASE_ICO_1) ico_phase_1_end = ico_start.add(SECONDS_IN_DAY.mul(ico_phase_1_days)); if (phase_i < PHASE_ICO_2) ico_phase_2_end = ico_phase_1_end.add(SECONDS_IN_DAY.mul(ico_phase_2_days)); if (phase_i < PHASE_ICO_3) ico_phase_3_end = ico_phase_2_end.add(SECONDS_IN_DAY.mul(ico_phase_3_days)); if (phase_i < PHASE_ICO_4) ico_phase_4_end = ico_phase_3_end.add(SECONDS_IN_DAY.mul(ico_phase_4_days)); if (phase_i < PHASE_ICO_5) ico_phase_5_end = ico_phase_4_end.add(SECONDS_IN_DAY.mul(ico_phase_5_days)); if (phase_i != PHASE_ICO_FINISHED) finish_date = ico_phase_5_end.add(SECONDS_IN_DAY.mul(10)); _updatePhase(false); } /** * @dev Send tokens to the specified address * * @param _to Address sent to * @param _amount_coin Amount of tockens * @return excess coins * * executed by CRM */ function transferICO(address _to, uint256 _amount_coin) public onlyOwnerOrManager { _updatePhase(true); uint256 remainedCoin = token.balanceOf(base_wallet); require(remainedCoin >= _amount_coin, "Not enough coins"); token.transferICO(_to, _amount_coin); if (remainedCoin == _amount_coin) _finalizeICO(); } /** * @dev Default contract function. Buy tokens by sending ethereums */ function() public payable { _updatePhase(true); address sender = msg.sender; uint256 amountEth = msg.value; uint256 remainedCoin = token.balanceOf(base_wallet); if (remainedCoin == 0) { sender.transfer(amountEth); _finalizeICO(); } else { uint8 percent = bonus_percents[uint256(phase_i)]; uint256 amountCoin = calcTokensFromEth(amountEth); assert(amountCoin >= MIN_TOKEN_AMOUNT); if (amountCoin > remainedCoin) { lastPayerOverflow = amountCoin.sub(remainedCoin); amountCoin = remainedCoin; } base_wallet.transfer(amountEth); token.transferICO(sender, amountCoin); _addPayment(sender, amountEth, amountCoin, percent); if (amountCoin == remainedCoin) _finalizeICO(); } } function calcTokensFromEth(uint256 ethAmount) internal view returns (uint256) { uint8 percent = bonus_percents[uint256(phase_i)]; uint256 bonusRate = uint256(percent).add(100); uint256 totalCoins = ethAmount.mul(exchange_rate).div(1000); uint256 totalFullCoins = (totalCoins.add(dec_mul.div(2))).div(dec_mul); uint256 tokensWithBonusX100 = bonusRate.mul(totalFullCoins); uint256 fullCoins = (tokensWithBonusX100.add(50)).div(100); return fullCoins.mul(dec_mul); } /** * @dev Freeze the account * @param _accounts Given accounts * * executed by CRM */ function freeze(address[] _accounts) public onlyOwnerOrManager { require(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED, "Bad phase"); uint i; for (i = 0; i < _accounts.length; i++) { require(_accounts[i] != address(0), "Zero address"); require(_accounts[i] != base_wallet, "Freeze self"); } for (i = 0; i < _accounts.length; i++) { token.freeze(_accounts[i]); } } /** * @dev Unfreeze the account * @param _accounts Given accounts */ function unfreeze(address[] _accounts) public onlyOwnerOrManager { require(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED, "Bad phase"); uint i; for (i = 0; i < _accounts.length; i++) { require(_accounts[i] != address(0), "Zero address"); require(_accounts[i] != base_wallet, "Freeze self"); } for (i = 0; i < _accounts.length; i++) { token.unfreeze(_accounts[i]); } } /** * @dev get ICO times * @return presale_start, presale_end, ico_start, ico_phase_1_end, ico_phase_2_end, ico_phase_3_end, ico_phase_4_end, ico_phase_5_end */ function getTimes() public view returns (uint, uint, uint, uint, uint, uint, uint, uint) { return (presale_start, presale_end, ico_start, ico_phase_1_end, ico_phase_2_end, ico_phase_3_end, ico_phase_4_end, ico_phase_5_end); } /** * @dev Sets start and end dates for pre-sale phase_i * @param _presale_start Pre-sale sart date * @param _presale_end Pre-sale end date */ function setPresaleDates(uint _presale_start, uint _presale_end) public onlyOwnerOrManager { _updatePhase(false); require(phase_i == PHASE_BEFORE_PRESALE, "Bad phase"); // require(_presale_start >= now); require(_presale_start < _presale_end, "Invalid presale dates"); require(_presale_end < ico_start, "Invalid dates"); presale_start = _presale_start; presale_end = _presale_end; } /** * @dev Sets start date for ICO phases * @param _ico_start ICO start date * @param _ico_1_days Days of ICO phase 1 * @param _ico_2_days Days of ICO phase 2 * @param _ico_3_days Days of ICO phase 3 * @param _ico_4_days Days of ICO phase 4 * @param _ico_5_days Days of ICO phase 5 */ function setICODates(uint _ico_start, uint _ico_1_days, uint _ico_2_days, uint _ico_3_days, uint _ico_4_days, uint _ico_5_days) public onlyOwnerOrManager { _updatePhase(false); require(phase_i != PHASE_FINISHED && phase_i != PHASE_ICO_FINISHED && phase_i < PHASE_ICO_1, "Bad phase"); require(presale_end < _ico_start, "Invalid dates"); ico_start = _ico_start; ico_phase_1_days = _ico_1_days; ico_phase_2_days = _ico_2_days; ico_phase_3_days = _ico_3_days; ico_phase_4_days = _ico_4_days; ico_phase_5_days = _ico_5_days; _updatePhaseTimes(); } }
contract CrowdSale is Ownable { using SafeMath for uint256; event Payment( address wallet, uint date, uint256 amountEth, uint256 amountCoin, uint8 bonusPercent ); uint constant internal MIN_TOKEN_AMOUNT = 5000; uint constant internal SECONDS_IN_DAY = 86400; // 24 * 60 * 60 uint constant internal SECONDS_IN_YEAR = 31557600; // ( 365 * 24 + 6 ) * 60 * 60 int8 constant internal PHASE_NOT_STARTED = -5; int8 constant internal PHASE_BEFORE_PRESALE = -4; int8 constant internal PHASE_BETWEEN_PRESALE_ICO = -3; int8 constant internal PHASE_ICO_FINISHED = -2; int8 constant internal PHASE_FINISHED = -1; int8 constant internal PHASE_PRESALE = 0; int8 constant internal PHASE_ICO_1 = 1; int8 constant internal PHASE_ICO_2 = 2; int8 constant internal PHASE_ICO_3 = 3; int8 constant internal PHASE_ICO_4 = 4; int8 constant internal PHASE_ICO_5 = 5; address internal manager; EyeToken internal token; address internal base_wallet; uint256 internal dec_mul; address internal vest_1; address internal vest_2; address internal vest_3; address internal vest_4; int8 internal phase_i; // see PHASE_XXX uint internal presale_start = 1533020400; // 2018-07-31 07:00 UTC uint internal presale_end = 1534316400; // 2018-08-15 07:00 UTC uint internal ico_start = 1537254000; // 2018-09-18 07:00 UTC uint internal ico_phase_1_days = 7; uint internal ico_phase_2_days = 7; uint internal ico_phase_3_days = 7; uint internal ico_phase_4_days = 7; uint internal ico_phase_5_days = 7; uint internal ico_phase_1_end; uint internal ico_phase_2_end; uint internal ico_phase_3_end; uint internal ico_phase_4_end; uint internal ico_phase_5_end; uint8[6] public bonus_percents = [50, 40, 30, 20, 10, 0]; uint internal finish_date; uint public exchange_rate; // tokens in one ethereum * 1000 uint256 public lastPayerOverflow = 0; /** * @dev Crowd-sale constructor */ function CrowdSale() Ownable() public { phase_i = PHASE_NOT_STARTED; manager = address(0); } /** * @dev Allow only for owner or manager */ modifier onlyOwnerOrManager(){ require(msg.sender == owner || (msg.sender == manager && manager != address(0)), "Invalid owner or manager"); _; } /** * @dev Returns current manager */ function getManager() public view onlyOwnerOrManager returns (address) { return manager; } /** * @dev Sets new manager * @param _manager New manager */ function setManager(address _manager) public onlyOwner { manager = _manager; } /** * @dev Set exchange rate * @param _rate New exchange rate * * executed by CRM */ function setRate(uint _rate) public onlyOwnerOrManager { require(_rate > 0, "Invalid exchange rate"); exchange_rate = _rate; } function _addPayment(address wallet, uint256 amountEth, uint256 amountCoin, uint8 bonusPercent) internal { emit Payment(wallet, now, amountEth, amountCoin, bonusPercent); } /** * @dev Start crowd-sale * @param _token Coin&#39;s contract * @param _rate current exchange rate */ function start(address _token, uint256 _rate) public onlyOwnerOrManager { require(_rate > 0, "Invalid exchange rate"); require(phase_i == PHASE_NOT_STARTED, "Bad phase"); token = EyeToken(_token); base_wallet = token.wallet(); dec_mul = 10 ** uint256(token.decimals()); // Organizasional expenses address org_exp = 0xeb967ECF00e86F58F6EB8019d003c48186679A96; // Early birds address ear_brd = 0x469A97b357C2056B927fF4CA097513BD927db99E; // Community development address com_dev = 0x877D6a4865478f50219a20870Bdd16E6f7aa954F; // Special coins address special = 0x5D2C58e6aCC5BcC1aaA9b54B007e0c9c3E091adE; // Team lock vest_1 = 0x47997109aE9bEd21efbBBA362957F1b20F435BF3; vest_2 = 0xd031B38d0520aa10450046Dc0328447C3FF59147; vest_3 = 0x32FcE00BfE1fEC48A45DC543224748f280a5c69E; vest_4 = 0x07B489712235197736E207836f3B71ffaC6b1220; token.transferICO(org_exp, 600000000 * dec_mul); token.transferICO(ear_brd, 1000000000 * dec_mul); token.transferICO(com_dev, 1000000000 * dec_mul); token.transferICO(special, 800000000 * dec_mul); token.transferICO(vest_1, 500000000 * dec_mul); token.transferICO(vest_2, 500000000 * dec_mul); token.transferICO(vest_3, 500000000 * dec_mul); token.transferICO(vest_4, 500000000 * dec_mul); exchange_rate = _rate; phase_i = PHASE_BEFORE_PRESALE; _updatePhaseTimes(); } /** * @dev Finalize ICO */ function _finalizeICO() internal { require(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED, "Bad phase"); phase_i = PHASE_ICO_FINISHED; uint curr_date = now; finish_date = (curr_date < ico_phase_5_end ? ico_phase_5_end : curr_date).add(SECONDS_IN_DAY * 10); } /** * @dev Finalize crowd-sale */ function _finalize() internal { require(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED, "Bad phase"); uint date = now.add(SECONDS_IN_YEAR); token.freeze(vest_1, date); date = date.add(SECONDS_IN_YEAR); token.freeze(vest_2, date); date = date.add(SECONDS_IN_YEAR); token.freeze(vest_3, date); date = date.add(SECONDS_IN_YEAR); token.freeze(vest_4, date); token.finalizeICO(); token.transferOwnership(base_wallet); phase_i = PHASE_FINISHED; } /** * @dev Finalize crowd-sale */ function finalize() public onlyOwner { _finalize(); } function _calcPhase() internal view returns (int8) { if (phase_i == PHASE_FINISHED || phase_i == PHASE_NOT_STARTED) return phase_i; uint curr_date = now; if (curr_date >= ico_phase_5_end || token.balanceOf(base_wallet) == 0) return PHASE_ICO_FINISHED; if (curr_date < presale_start) return PHASE_BEFORE_PRESALE; if (curr_date <= presale_end) return PHASE_PRESALE; if (curr_date < ico_start) return PHASE_BETWEEN_PRESALE_ICO; if (curr_date < ico_phase_1_end) return PHASE_ICO_1; if (curr_date < ico_phase_2_end) return PHASE_ICO_2; if (curr_date < ico_phase_3_end) return PHASE_ICO_3; if (curr_date < ico_phase_4_end) return PHASE_ICO_4; return PHASE_ICO_5; } function phase() public view returns (int8) { return _calcPhase(); } /** * @dev Recalculate phase */ function _updatePhase(bool check_can_sale) internal { uint curr_date = now; if (phase_i == PHASE_ICO_FINISHED) { if (curr_date >= finish_date) _finalize(); } else if (phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED) { int8 new_phase = _calcPhase(); if (new_phase == PHASE_ICO_FINISHED && phase_i != PHASE_ICO_FINISHED) _finalizeICO(); else phase_i = new_phase; } if (check_can_sale) require(phase_i >= 0, "Bad phase"); } /** * @dev Update phase end times */ function _updatePhaseTimes() internal { require(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED, "Bad phase"); if (phase_i < PHASE_ICO_1) ico_phase_1_end = ico_start.add(SECONDS_IN_DAY.mul(ico_phase_1_days)); if (phase_i < PHASE_ICO_2) ico_phase_2_end = ico_phase_1_end.add(SECONDS_IN_DAY.mul(ico_phase_2_days)); if (phase_i < PHASE_ICO_3) ico_phase_3_end = ico_phase_2_end.add(SECONDS_IN_DAY.mul(ico_phase_3_days)); if (phase_i < PHASE_ICO_4) ico_phase_4_end = ico_phase_3_end.add(SECONDS_IN_DAY.mul(ico_phase_4_days)); if (phase_i < PHASE_ICO_5) ico_phase_5_end = ico_phase_4_end.add(SECONDS_IN_DAY.mul(ico_phase_5_days)); if (phase_i != PHASE_ICO_FINISHED) finish_date = ico_phase_5_end.add(SECONDS_IN_DAY.mul(10)); _updatePhase(false); } /** * @dev Send tokens to the specified address * * @param _to Address sent to * @param _amount_coin Amount of tockens * @return excess coins * * executed by CRM */ function transferICO(address _to, uint256 _amount_coin) public onlyOwnerOrManager { _updatePhase(true); uint256 remainedCoin = token.balanceOf(base_wallet); require(remainedCoin >= _amount_coin, "Not enough coins"); token.transferICO(_to, _amount_coin); if (remainedCoin == _amount_coin) _finalizeICO(); } /** * @dev Default contract function. Buy tokens by sending ethereums */ function() public payable { _updatePhase(true); address sender = msg.sender; uint256 amountEth = msg.value; uint256 remainedCoin = token.balanceOf(base_wallet); if (remainedCoin == 0) { sender.transfer(amountEth); _finalizeICO(); } else { uint8 percent = bonus_percents[uint256(phase_i)]; uint256 amountCoin = calcTokensFromEth(amountEth); assert(amountCoin >= MIN_TOKEN_AMOUNT); if (amountCoin > remainedCoin) { lastPayerOverflow = amountCoin.sub(remainedCoin); amountCoin = remainedCoin; } base_wallet.transfer(amountEth); token.transferICO(sender, amountCoin); _addPayment(sender, amountEth, amountCoin, percent); if (amountCoin == remainedCoin) _finalizeICO(); } } function calcTokensFromEth(uint256 ethAmount) internal view returns (uint256) { uint8 percent = bonus_percents[uint256(phase_i)]; uint256 bonusRate = uint256(percent).add(100); uint256 totalCoins = ethAmount.mul(exchange_rate).div(1000); uint256 totalFullCoins = (totalCoins.add(dec_mul.div(2))).div(dec_mul); uint256 tokensWithBonusX100 = bonusRate.mul(totalFullCoins); uint256 fullCoins = (tokensWithBonusX100.add(50)).div(100); return fullCoins.mul(dec_mul); } /** * @dev Freeze the account * @param _accounts Given accounts * * executed by CRM */ function freeze(address[] _accounts) public onlyOwnerOrManager { require(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED, "Bad phase"); uint i; for (i = 0; i < _accounts.length; i++) { require(_accounts[i] != address(0), "Zero address"); require(_accounts[i] != base_wallet, "Freeze self"); } for (i = 0; i < _accounts.length; i++) { token.freeze(_accounts[i]); } } /** * @dev Unfreeze the account * @param _accounts Given accounts */ function unfreeze(address[] _accounts) public onlyOwnerOrManager { require(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED, "Bad phase"); uint i; for (i = 0; i < _accounts.length; i++) { require(_accounts[i] != address(0), "Zero address"); require(_accounts[i] != base_wallet, "Freeze self"); } for (i = 0; i < _accounts.length; i++) { token.unfreeze(_accounts[i]); } } /** * @dev get ICO times * @return presale_start, presale_end, ico_start, ico_phase_1_end, ico_phase_2_end, ico_phase_3_end, ico_phase_4_end, ico_phase_5_end */ function getTimes() public view returns (uint, uint, uint, uint, uint, uint, uint, uint) { return (presale_start, presale_end, ico_start, ico_phase_1_end, ico_phase_2_end, ico_phase_3_end, ico_phase_4_end, ico_phase_5_end); } /** * @dev Sets start and end dates for pre-sale phase_i * @param _presale_start Pre-sale sart date * @param _presale_end Pre-sale end date */ function setPresaleDates(uint _presale_start, uint _presale_end) public onlyOwnerOrManager { _updatePhase(false); require(phase_i == PHASE_BEFORE_PRESALE, "Bad phase"); // require(_presale_start >= now); require(_presale_start < _presale_end, "Invalid presale dates"); require(_presale_end < ico_start, "Invalid dates"); presale_start = _presale_start; presale_end = _presale_end; } /** * @dev Sets start date for ICO phases * @param _ico_start ICO start date * @param _ico_1_days Days of ICO phase 1 * @param _ico_2_days Days of ICO phase 2 * @param _ico_3_days Days of ICO phase 3 * @param _ico_4_days Days of ICO phase 4 * @param _ico_5_days Days of ICO phase 5 */ function setICODates(uint _ico_start, uint _ico_1_days, uint _ico_2_days, uint _ico_3_days, uint _ico_4_days, uint _ico_5_days) public onlyOwnerOrManager { _updatePhase(false); require(phase_i != PHASE_FINISHED && phase_i != PHASE_ICO_FINISHED && phase_i < PHASE_ICO_1, "Bad phase"); require(presale_end < _ico_start, "Invalid dates"); ico_start = _ico_start; ico_phase_1_days = _ico_1_days; ico_phase_2_days = _ico_2_days; ico_phase_3_days = _ico_3_days; ico_phase_4_days = _ico_4_days; ico_phase_5_days = _ico_5_days; _updatePhaseTimes(); } }
41,622
90
// This is a packed array of booleans.
mapping(uint256 => uint256) private claimedBitMap; uint256 public immutable ownerUnlockTime; constructor( address _owner, address _token, bytes32 _merkleRoot, uint256 _daysUntilUnlock
mapping(uint256 => uint256) private claimedBitMap; uint256 public immutable ownerUnlockTime; constructor( address _owner, address _token, bytes32 _merkleRoot, uint256 _daysUntilUnlock
15,929
22
// so the bit shift does not overflow
require(upper <= uint112(-1), 'FixedPoint::muluq: upper overflow');
require(upper <= uint112(-1), 'FixedPoint::muluq: upper overflow');
25,079
0
// Controller that contract is registered with
IController public controller;
IController public controller;
35,640
154
// function to know how much LXT tokens are pending to be claimed for an address bidder address to queryreturn the total claimable LXT by an address /
function getClaimableLXT(address bidder) public view returns (uint128) { return pendingBalances[bidder]; }
function getClaimableLXT(address bidder) public view returns (uint128) { return pendingBalances[bidder]; }
81,547
96
// using SafeERC20 for IERC20;
using UniversalERC20 for IERC20; using Address for address; using SafeMath for uint256; using UniswapV2ExchangeLib for IUniswapV2Exchange;
using UniversalERC20 for IERC20; using Address for address; using SafeMath for uint256; using UniswapV2ExchangeLib for IUniswapV2Exchange;
11,706
190
// Resets royalty information for the token id back to the global default. /
function _resetTokenRoyalty(uint256 tokenId) internal virtual { delete _tokenRoyaltyInfo[tokenId]; }
function _resetTokenRoyalty(uint256 tokenId) internal virtual { delete _tokenRoyaltyInfo[tokenId]; }
6,054
168
// unstakes vote tokens_amount amount of vote tokens to unstake /
function unstake(uint256 _amount) public greaterThanZero(_amount) { require(voteLocks[msg.sender] < block.timestamp, "ERR_LOCKED"); // reduce votes for user votes[msg.sender] = votesOf(msg.sender).sub(_amount); // reduce total votes totalVotes = totalVotes.sub(_amount); // transfer tokens back govToken.safeTransfer(msg.sender, _amount); // emit unstaked event emit Unstaked(msg.sender, _amount); }
function unstake(uint256 _amount) public greaterThanZero(_amount) { require(voteLocks[msg.sender] < block.timestamp, "ERR_LOCKED"); // reduce votes for user votes[msg.sender] = votesOf(msg.sender).sub(_amount); // reduce total votes totalVotes = totalVotes.sub(_amount); // transfer tokens back govToken.safeTransfer(msg.sender, _amount); // emit unstaked event emit Unstaked(msg.sender, _amount); }
30,494
154
// verify input data&39;s basic integrity.
function verifyInputDataIntegrity(RingParams params) private pure
function verifyInputDataIntegrity(RingParams params) private pure
29,248
15
// minterreturn minter's address. /
function minter() external view returns(address)
function minter() external view returns(address)
1,027
4
// The address of the WBNB contract, so that BNB can be transferred via WBNB if native BNB transfers fail.
address public WBNBAddress; uint256 public tradingFee; // swap fee as percent - percent divider = 1000 address public feeAddress;
address public WBNBAddress; uint256 public tradingFee; // swap fee as percent - percent divider = 1000 address public feeAddress;
43,878
5
// Function to disapprove a campaign
function disapproveCampaign(address campaignAddress) public onlyCampaignOwner(campaignAddress) { require(isCampaign[campaignAddress], "Campaign does not exist"); TokenRewardCampaign(campaignAddress).withdrawFunds(); emit CampaignDisapproved(campaignAddress); }
function disapproveCampaign(address campaignAddress) public onlyCampaignOwner(campaignAddress) { require(isCampaign[campaignAddress], "Campaign does not exist"); TokenRewardCampaign(campaignAddress).withdrawFunds(); emit CampaignDisapproved(campaignAddress); }
3,158
41
// Remove contract
function removeContract() onlyOwner public { selfdestruct(wallet); }
function removeContract() onlyOwner public { selfdestruct(wallet); }
3,248
22
// Hook called by the Vault on swaps to quote prices and execute trade/swapRequest The request which contains the details of the swap/ currentBalanceTokenIn The input token balance scaled to the base token decimals that the assimilators expect/ currentBalanceTokenOut The output token balance scaled to the quote token decimals (6 for USDC) that the assimilators expect/ return the amount of the output or input token amount of for swap
function onSwap( SwapRequest memory swapRequest, uint256, uint256
function onSwap( SwapRequest memory swapRequest, uint256, uint256
8,165
36
// Add a new lp to the pool. Can only be called by the owner. _allocPoint is the weight assigned to this pool, which will be used to calculate rewards for liquidity providers. This number will be added to totalAllocPoint which is used to calculate the relative weight of each pool. _want Address of the want token. _withUpdate Boolean that indicates whether to call massUpdatePools or not,which in turn will call updatePool for each pool. updatePool will update reward relatedvariables as accELIXIRPerShare, lastRewardBlock for a given pool. _strat Strategy address that will ELIXIR compound want tokens Do not add the same
function addPool( uint256 _allocPoint, IERC20 _want, bool _withUpdate, address _strat
function addPool( uint256 _allocPoint, IERC20 _want, bool _withUpdate, address _strat
15,613
105
// This amount must be determined before arNxm burn.
uint256 wNxmAmount = wNxmValue(_arAmount);
uint256 wNxmAmount = wNxmValue(_arAmount);
19,881
593
// Sets a custom liveness value for the request. Liveness is the amount of time a proposal must wait beforebeing auto-resolved. identifier price identifier to identify the existing request. timestamp timestamp to identify the existing request. ancillaryData ancillary data of the price being requested. customLiveness new custom liveness. /
function setCustomLiveness(
function setCustomLiveness(
3,927
118
// weiAmount(fee %)(EDO/Wei) / (decimals in edo/wei) / (decimals in percentage)
if (!__isSell__(makerOrder)) {
if (!__isSell__(makerOrder)) {
41,737
42
// startIco starts the public ICO /
function startIco() public onlyOwner { require(currentStage != Stages.icoEnd); currentStage = Stages.icoStart; }
function startIco() public onlyOwner { require(currentStage != Stages.icoEnd); currentStage = Stages.icoStart; }
3,250
33
// Approve the spending of all assets by their corresponding pool tokens, if for some reason is it necessary. /
function safeApproveAllTokens() external { // This strategy is a special case since it only supports one asset for (uint256 i = 0; i < assetsMapped.length; i++) { _abstractSetPToken(assetsMapped[i], assetToPToken[assetsMapped[i]]); } }
function safeApproveAllTokens() external { // This strategy is a special case since it only supports one asset for (uint256 i = 0; i < assetsMapped.length; i++) { _abstractSetPToken(assetsMapped[i], assetToPToken[assetsMapped[i]]); } }
2,724
24
// We calculate the new total supply of cTokens and minter token balance, checking for overflow: totalSupply = totalSupply + mintTokens accountTokens[minter] = accountTokens[minter] + mintTokens /
totalSupply = add_(totalSupply, vars.mintTokens);
totalSupply = add_(totalSupply, vars.mintTokens);
65,073
96
// calculate true bond price a user pays return price_ uint /
function trueBondPrice() public view returns ( uint price_ ) { price_ = bondPrice().add(bondPrice().mul( currentOlympusFee() ).div( 1e6 ) ); }
function trueBondPrice() public view returns ( uint price_ ) { price_ = bondPrice().add(bondPrice().mul( currentOlympusFee() ).div( 1e6 ) ); }
12,491
33
// Reject all ERC23 compatible tokensfrom_ address The address that is transferring the tokensvalue_ uint256 the amount of the specified tokendata_ Bytes The data passed from the caller./
function tokenFallback(address from_, uint256 value_, bytes data_) pure external { from_; value_; data_; revert(); }
function tokenFallback(address from_, uint256 value_, bytes data_) pure external { from_; value_; data_; revert(); }
20,608
165
// There are not enough EXN tokens in the contract for bonus payout (workaround: set `bonus` to zero)
error CoreTokenBalanceTooLow(uint256);
error CoreTokenBalanceTooLow(uint256);
17,946
16
// updated the accumulated quota
ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum);
ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum);
21,559
202
// Ok, go ahead with the update.
_setRate(currencyKey, newRates[i], timeSent);
_setRate(currencyKey, newRates[i], timeSent);
3,632
107
// Mapping of ERC721 address -> ID -> tokenAddress -> IDs -> amounts
mapping(address => mapping(uint256 => mapping(address => mapping(uint256 => uint256)))) public erc1155Rewards;
mapping(address => mapping(uint256 => mapping(address => mapping(uint256 => uint256)))) public erc1155Rewards;
15,544
219
// Level up the hero with _tokenId.This function is called by the owner of the hero.
function levelUp(uint256 _tokenId) onlyOwnerOf(_tokenId) whenNotPaused public
function levelUp(uint256 _tokenId) onlyOwnerOf(_tokenId) whenNotPaused public
22,198
28
// The TokenRegistry is a basic registry mapping token symbolsto their known, deployed addresses on the current blockchain. Note that the TokenRegistry does not mediate any of thecore protocol's business logic, but, rather, is a helpfulutility for Terms Contracts to use in encoding, decoding, andresolving the addresses of currently deployed tokens. At this point in time, administration of the Token Registry isunder Dharma Labs' control.With more sophisticated decentralizedgovernance mechanisms, we intend to shift ownership of this utilitycontract to the Dharma community. /
contract TokenRegistry is Ownable { mapping (bytes32 => TokenAttributes) public symbolHashToTokenAttributes; string[256] public tokenSymbolList; uint8 public tokenSymbolListLength; struct TokenAttributes { // The ERC20 contract address. address tokenAddress; // The index in `tokenSymbolList` where the token's symbol can be found. uint tokenIndex; // The name of the given token, e.g. "Canonical Wrapped Ether" string name; // The number of digits that come after the decimal place when displaying token value. uint8 numDecimals; } /** * Maps the given symbol to the given token attributes. */ function setTokenAttributes( string _symbol, address _tokenAddress, string _tokenName, uint8 _numDecimals ) public onlyOwner { bytes32 symbolHash = keccak256(_symbol); // Attempt to retrieve the token's attributes from the registry. TokenAttributes memory attributes = symbolHashToTokenAttributes[symbolHash]; if (attributes.tokenAddress == address(0)) { // The token has not yet been added to the registry. attributes.tokenAddress = _tokenAddress; attributes.numDecimals = _numDecimals; attributes.name = _tokenName; attributes.tokenIndex = tokenSymbolListLength; tokenSymbolList[tokenSymbolListLength] = _symbol; tokenSymbolListLength++; } else { // The token has already been added to the registry; update attributes. attributes.tokenAddress = _tokenAddress; attributes.numDecimals = _numDecimals; attributes.name = _tokenName; } // Update this contract's storage. symbolHashToTokenAttributes[symbolHash] = attributes; } /** * Given a symbol, resolves the current address of the token the symbol is mapped to. */ function getTokenAddressBySymbol(string _symbol) public view returns (address) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.tokenAddress; } /** * Given the known index of a token within the registry's symbol list, * returns the address of the token mapped to the symbol at that index. * * This is a useful utility for compactly encoding the address of a token into a * TermsContractParameters string -- by encoding a token by its index in a * a 256 slot array, we can represent a token by a 1 byte uint instead of a 20 byte address. */ function getTokenAddressByIndex(uint _index) public view returns (address) { string storage symbol = tokenSymbolList[_index]; return getTokenAddressBySymbol(symbol); } /** * Given a symbol, resolves the index of the token the symbol is mapped to within the registry's * symbol list. */ function getTokenIndexBySymbol(string _symbol) public view returns (uint) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.tokenIndex; } /** * Given an index, resolves the symbol of the token at that index in the registry's * token symbol list. */ function getTokenSymbolByIndex(uint _index) public view returns (string) { return tokenSymbolList[_index]; } /** * Given a symbol, returns the name of the token the symbol is mapped to within the registry's * symbol list. */ function getTokenNameBySymbol(string _symbol) public view returns (string) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.name; } /** * Given the symbol for a token, returns the number of decimals as provided in * the associated TokensAttribute struct. * * Example: * getNumDecimalsFromSymbol("REP"); * => 18 */ function getNumDecimalsFromSymbol(string _symbol) public view returns (uint8) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.numDecimals; } /** * Given the index for a token in the registry, returns the number of decimals as provided in * the associated TokensAttribute struct. * * Example: * getNumDecimalsByIndex(1); * => 18 */ function getNumDecimalsByIndex(uint _index) public view returns (uint8) { string memory symbol = getTokenSymbolByIndex(_index); return getNumDecimalsFromSymbol(symbol); } /** * Given the index for a token in the registry, returns the name of the token as provided in * the associated TokensAttribute struct. * * Example: * getTokenNameByIndex(1); * => "Canonical Wrapped Ether" */ function getTokenNameByIndex(uint _index) public view returns (string) { string memory symbol = getTokenSymbolByIndex(_index); string memory tokenName = getTokenNameBySymbol(symbol); return tokenName; } /** * Given the symbol for a token in the registry, returns a tuple containing the token's address, * the token's index in the registry, the token's name, and the number of decimals. * * Example: * getTokenAttributesBySymbol("WETH"); * => ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", 1, "Canonical Wrapped Ether", 18] */ function getTokenAttributesBySymbol(string _symbol) public view returns ( address, uint, string, uint ) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return ( attributes.tokenAddress, attributes.tokenIndex, attributes.name, attributes.numDecimals ); } /** * Given the index for a token in the registry, returns a tuple containing the token's address, * the token's symbol, the token's name, and the number of decimals. * * Example: * getTokenAttributesByIndex(1); * => ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "WETH", "Canonical Wrapped Ether", 18] */ function getTokenAttributesByIndex(uint _index) public view returns ( address, string, string, uint8 ) { string memory symbol = getTokenSymbolByIndex(_index); bytes32 symbolHash = keccak256(symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return ( attributes.tokenAddress, symbol, attributes.name, attributes.numDecimals ); } }
contract TokenRegistry is Ownable { mapping (bytes32 => TokenAttributes) public symbolHashToTokenAttributes; string[256] public tokenSymbolList; uint8 public tokenSymbolListLength; struct TokenAttributes { // The ERC20 contract address. address tokenAddress; // The index in `tokenSymbolList` where the token's symbol can be found. uint tokenIndex; // The name of the given token, e.g. "Canonical Wrapped Ether" string name; // The number of digits that come after the decimal place when displaying token value. uint8 numDecimals; } /** * Maps the given symbol to the given token attributes. */ function setTokenAttributes( string _symbol, address _tokenAddress, string _tokenName, uint8 _numDecimals ) public onlyOwner { bytes32 symbolHash = keccak256(_symbol); // Attempt to retrieve the token's attributes from the registry. TokenAttributes memory attributes = symbolHashToTokenAttributes[symbolHash]; if (attributes.tokenAddress == address(0)) { // The token has not yet been added to the registry. attributes.tokenAddress = _tokenAddress; attributes.numDecimals = _numDecimals; attributes.name = _tokenName; attributes.tokenIndex = tokenSymbolListLength; tokenSymbolList[tokenSymbolListLength] = _symbol; tokenSymbolListLength++; } else { // The token has already been added to the registry; update attributes. attributes.tokenAddress = _tokenAddress; attributes.numDecimals = _numDecimals; attributes.name = _tokenName; } // Update this contract's storage. symbolHashToTokenAttributes[symbolHash] = attributes; } /** * Given a symbol, resolves the current address of the token the symbol is mapped to. */ function getTokenAddressBySymbol(string _symbol) public view returns (address) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.tokenAddress; } /** * Given the known index of a token within the registry's symbol list, * returns the address of the token mapped to the symbol at that index. * * This is a useful utility for compactly encoding the address of a token into a * TermsContractParameters string -- by encoding a token by its index in a * a 256 slot array, we can represent a token by a 1 byte uint instead of a 20 byte address. */ function getTokenAddressByIndex(uint _index) public view returns (address) { string storage symbol = tokenSymbolList[_index]; return getTokenAddressBySymbol(symbol); } /** * Given a symbol, resolves the index of the token the symbol is mapped to within the registry's * symbol list. */ function getTokenIndexBySymbol(string _symbol) public view returns (uint) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.tokenIndex; } /** * Given an index, resolves the symbol of the token at that index in the registry's * token symbol list. */ function getTokenSymbolByIndex(uint _index) public view returns (string) { return tokenSymbolList[_index]; } /** * Given a symbol, returns the name of the token the symbol is mapped to within the registry's * symbol list. */ function getTokenNameBySymbol(string _symbol) public view returns (string) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.name; } /** * Given the symbol for a token, returns the number of decimals as provided in * the associated TokensAttribute struct. * * Example: * getNumDecimalsFromSymbol("REP"); * => 18 */ function getNumDecimalsFromSymbol(string _symbol) public view returns (uint8) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.numDecimals; } /** * Given the index for a token in the registry, returns the number of decimals as provided in * the associated TokensAttribute struct. * * Example: * getNumDecimalsByIndex(1); * => 18 */ function getNumDecimalsByIndex(uint _index) public view returns (uint8) { string memory symbol = getTokenSymbolByIndex(_index); return getNumDecimalsFromSymbol(symbol); } /** * Given the index for a token in the registry, returns the name of the token as provided in * the associated TokensAttribute struct. * * Example: * getTokenNameByIndex(1); * => "Canonical Wrapped Ether" */ function getTokenNameByIndex(uint _index) public view returns (string) { string memory symbol = getTokenSymbolByIndex(_index); string memory tokenName = getTokenNameBySymbol(symbol); return tokenName; } /** * Given the symbol for a token in the registry, returns a tuple containing the token's address, * the token's index in the registry, the token's name, and the number of decimals. * * Example: * getTokenAttributesBySymbol("WETH"); * => ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", 1, "Canonical Wrapped Ether", 18] */ function getTokenAttributesBySymbol(string _symbol) public view returns ( address, uint, string, uint ) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return ( attributes.tokenAddress, attributes.tokenIndex, attributes.name, attributes.numDecimals ); } /** * Given the index for a token in the registry, returns a tuple containing the token's address, * the token's symbol, the token's name, and the number of decimals. * * Example: * getTokenAttributesByIndex(1); * => ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "WETH", "Canonical Wrapped Ether", 18] */ function getTokenAttributesByIndex(uint _index) public view returns ( address, string, string, uint8 ) { string memory symbol = getTokenSymbolByIndex(_index); bytes32 symbolHash = keccak256(symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return ( attributes.tokenAddress, symbol, attributes.name, attributes.numDecimals ); } }
40,219
49
// disables/enables token issuance/ can only be called by the contract owner
function disableIssuance() public onlyOwner onlyIf(issuanceEnabled)
function disableIssuance() public onlyOwner onlyIf(issuanceEnabled)
36,060
228
// ========== ADDRESS RESOLVER CONFIGURATION ========== / ========== CONSTRUCTOR ==========
constructor( address payable _proxy, TokenState _tokenState, address _owner, uint256 _totalSupply, address _resolver ) public ExternStateToken(
constructor( address payable _proxy, TokenState _tokenState, address _owner, uint256 _totalSupply, address _resolver ) public ExternStateToken(
13,281
68
// Defines the Starterpack parameters
struct Pack { StickerMarket stickerMarket; // Sticker market contract for minting the sticker pack ids uint256 ethAmount; // The Amount of ETH to transfer to the recipient address[] tokens; // Array of ERC20 Contract Addresses uint256[] tokenAmounts; // Array of ERC20 amounts corresponding to cells in tokens[] uint256[] stickerPackIds; // Array of NFT's }
struct Pack { StickerMarket stickerMarket; // Sticker market contract for minting the sticker pack ids uint256 ethAmount; // The Amount of ETH to transfer to the recipient address[] tokens; // Array of ERC20 Contract Addresses uint256[] tokenAmounts; // Array of ERC20 amounts corresponding to cells in tokens[] uint256[] stickerPackIds; // Array of NFT's }
37,444
47
// Logged when a particular account is frozen. /
event FrozenFunds(address target, bool frozen);
event FrozenFunds(address target, bool frozen);
16,871
5
// Checks if account is blacklisted _account The address to check /
function isBlacklisted(address _account) public view returns (bool) { return blacklisted[_account]; }
function isBlacklisted(address _account) public view returns (bool) { return blacklisted[_account]; }
15,725
17
// return The total number of fragments. /
function totalSupply() public view override returns (uint256) { return getCiculatingBalance().add(getLockedBalance()); }
function totalSupply() public view override returns (uint256) { return getCiculatingBalance().add(getLockedBalance()); }
27,162