| contract_name
				 stringlengths 1 61 | file_path
				 stringlengths 5 50.4k | contract_address
				 stringlengths 42 42 | language
				 stringclasses 1
				value | class_name
				 stringlengths 1 61 | class_code
				 stringlengths 4 330k | class_documentation
				 stringlengths 0 29.1k | class_documentation_type
				 stringclasses 6
				values | func_name
				 stringlengths 0 62 | func_code
				 stringlengths 1 303k | func_documentation
				 stringlengths 2 14.9k | func_documentation_type
				 stringclasses 4
				values | compiler_version
				 stringlengths 15 42 | license_type
				 stringclasses 14
				values | swarm_source
				 stringlengths 0 71 | meta
				 dict | __index_level_0__
				 int64 0 60.4k | 
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	GlobalsAndUtility | 
	contract GlobalsAndUtility is ERC20 {
    /*  XfLobbyEnter
    */
    event XfLobbyEnter(
        uint256 timestamp,
        uint256 enterDay,
        uint256 indexed entryIndex,
        uint256 indexed rawAmount
    );
    /*  XfLobbyExit 
    */
    event XfLobbyExit(
        uint256 timestamp,
        uint256 enterDay,
        uint256 indexed entryIndex,
        uint256 indexed xfAmount,
        address indexed referrerAddr
    );
    /*  DailyDataUpdate
    */
    event DailyDataUpdate(
        address indexed updaterAddr,
        uint256 timestamp,
        uint256 beginDay,
        uint256 endDay
    );
    /*  StakeStart
    */
    event StakeStart(
        uint40 indexed stakeId,
        address indexed stakerAddr,
        uint256 stakedGuns,
        uint256 stakeShares,
        uint256 stakedDays
    );
    
    /*  StakeGoodAccounting
    */
    event StakeGoodAccounting(
        uint40 indexed stakeId,
        address indexed stakerAddr,
        address indexed senderAddr,
        uint256 stakedGuns,
        uint256 stakeShares,
        uint256 payout,
        uint256 penalty
    );
    /*  StakeEnd 
    */
    event StakeEnd(
        uint40 indexed stakeId,
        uint40 prevUnlocked,
        address indexed stakerAddr,
        uint256 lockedDay,
        uint256 servedDays,
        uint256 stakedGuns,
        uint256 stakeShares,
        uint256 dividends,
        uint256 payout,
        uint256 penalty,
        uint256 stakeReturn
    );
    /*  ShareRateChange 
    */
    event ShareRateChange(
        uint40 indexed stakeId,
        uint256 timestamp,
        uint256 newShareRate
    );
    /* 	CSN allocation share address
	*	Used for 5% drip into CSN auction
	*	95% of the first 2 days public auction will be redistributed over the next 30 days to balance auction lobby healthy.
	*/
    address payable internal constant FLUSH_ADDR = 0xcE3D57d817dC3B83899907BFec99C7EF2E2AF35d;
    uint8 internal LAST_FLUSHED_DAY = 1;
    /* ERC20 constants */
    string public constant name = "Community Staking Network in ETH";
    string public constant symbol = "CSNE";
    uint8 public constant decimals = 8;
    /* Suns per Satoshi = 10,000 * 1e8 / 1e8 = 1e4 */
    uint256 private constant SUNS_PER_DIV = 10 ** uint256(decimals); // 1e8
    /* Time of contract launch (Dec 7th, 00:00:00 UTC, Auction Day 1 Starts Dec 8th, 00:00:00 UTC) */
    uint256 internal constant LAUNCH_TIME = 1607299200;
    /* Start of claim phase */
    uint256 internal constant PRE_CLAIM_DAYS = 1;
    /* reduce amount of tokens to 2500000 */
    uint256 internal constant CLAIM_STARTING_AMOUNT = 2500000 * (10 ** 8);
    /* reduce amount of tokens to 1000000 */
    uint256 internal constant CLAIM_LOWEST_AMOUNT = 1000000 * (10 ** 8);
    uint256 internal constant CLAIM_PHASE_START_DAY = PRE_CLAIM_DAYS;
    /* Number of words to hold 1 bit for each transform lobby day */
    uint256 internal constant XF_LOBBY_DAY_WORDS = ((1 + (50 * 7)) + 255) >> 8;
    /* Stake timing parameters */
    uint256 internal constant MIN_STAKE_DAYS = 1;
    uint256 internal constant MAX_STAKE_DAYS = 30; //1 month
    uint256 internal constant EARLY_PENALTY_MIN_DAYS = 90;
    uint256 private constant LATE_PENALTY_GRACE_WEEKS = 2;
    uint256 internal constant LATE_PENALTY_GRACE_DAYS = LATE_PENALTY_GRACE_WEEKS * 7;
    uint256 private constant LATE_PENALTY_SCALE_WEEKS = 100;
    uint256 internal constant LATE_PENALTY_SCALE_DAYS = LATE_PENALTY_SCALE_WEEKS * 7;
    /* Stake shares Longer Pays Better bonus constants used by _stakeStartBonusGuns() */
    uint256 private constant LPB_BONUS_PERCENT = 20;
    uint256 private constant LPB_BONUS_MAX_PERCENT = 200;
    uint256 internal constant LPB = 364 * 100 / LPB_BONUS_PERCENT;
    uint256 internal constant LPB_MAX_DAYS = LPB * LPB_BONUS_MAX_PERCENT / 100;
    uint256 private constant BPB_BONUS_PERCENT = 10;
    uint256 private constant BPB_MAX_DIV = 7 * 1e6;
    uint256 internal constant BPB_MAX_SUNS = BPB_MAX_DIV * SUNS_PER_DIV;
    uint256 internal constant BPB = BPB_MAX_SUNS * 100 / BPB_BONUS_PERCENT;
    /* Share rate is scaled to increase precision */
    uint256 internal constant SHARE_RATE_SCALE = 1e5;	
    /* Share rate max (after scaling) */	
    uint256 internal constant SHARE_RATE_UINT_SIZE = 40;	
    uint256 internal constant SHARE_RATE_MAX = (1 << SHARE_RATE_UINT_SIZE) - 1;	
    /* weekly staking bonus */	
    uint8 internal constant BONUS_DAY_SCALE = 2;	
    /* Globals expanded for memory (except _latestStakeId) and compact for storage */	
    struct GlobalsCache {	
        uint256 _lockedSunsTotal;	
        uint256 _nextStakeSharesTotal;	
        uint256 _shareRate;	
        uint256 _stakePenaltyTotal;	
        uint256 _dailyDataCount;	
        uint256 _stakeSharesTotal;	
        uint40 _latestStakeId;	
        uint256 _currentDay;	
    }	
    struct GlobalsStore {	
        uint72 lockedSunsTotal;	
        uint72 nextStakeSharesTotal;	
        uint40 shareRate;	
        uint72 stakePenaltyTotal;	
        uint16 dailyDataCount;	
        uint72 stakeSharesTotal;	
        uint40 latestStakeId;	
    }	
    GlobalsStore public globals;	
    /* Daily data */	
    struct DailyDataStore {	
        uint72 dayPayoutTotal;	
        uint256 dayDividends;	
        uint72 dayStakeSharesTotal;	
    }	
    mapping(uint256 => DailyDataStore) public dailyData;	
    /* Stake expanded for memory (except _stakeId) and compact for storage */	
    struct StakeCache {	
        uint40 _stakeId;	
        uint256 _stakedSuns;	
        uint256 _stakeShares;	
        uint256 _lockedDay;	
        uint256 _stakedDays;	
        uint256 _unlockedDay;	
    }	
    struct StakeStore {	
        uint40 stakeId;	
        uint72 stakedSuns;	
        uint72 stakeShares;	
        uint16 lockedDay;	
        uint16 stakedDays;	
        uint16 unlockedDay;	
    }	
    mapping(address => StakeStore[]) public stakeLists;	
    /* Temporary state for calculating daily rounds */	
    struct DailyRoundState {	
        uint256 _allocSupplyCached;	
        uint256 _payoutTotal;	
    }	
    struct XfLobbyEntryStore {	
        uint96 rawAmount;	
        address referrerAddr;	
    }	
    struct XfLobbyQueueStore {	
        uint40 headIndex;	
        uint40 tailIndex;	
        mapping(uint256 => XfLobbyEntryStore) entries;	
    }	
    mapping(uint256 => uint256) public xfLobby;	
    mapping(uint256 => mapping(address => XfLobbyQueueStore)) public xfLobbyMembers;	
    /**	
     * @dev PUBLIC FACING: Optionally update daily data for a smaller	
     * range to reduce gas cost for a subsequent operation	
     * @param beforeDay Only update days before this day number (optional; 0 for current day)	
     */	
    function dailyDataUpdate(uint256 beforeDay)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* Skip pre-claim period */	
        require(g._currentDay > CLAIM_PHASE_START_DAY, "CSNE: Too early");	
        if (beforeDay != 0) {	
            require(beforeDay <= g._currentDay, "CSNE: beforeDay cannot be in the future");	
            _dailyDataUpdate(g, beforeDay, false);	
        } else {	
            /* Default to updating before current day */	
            _dailyDataUpdate(g, g._currentDay, false);	
        }	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: External helper to return multiple values of daily data with	
     * a single call.	
     * @param endDay Last day (non-inclusive) of data range	
     * @param beginDay First day of data range	
     * @return array of day stake shares total	
     * @return array of day payout total	
     */	
    function dailyDataRange(uint256 beginDay, uint256 endDay)	
        external	
        view	
        returns (uint256[] memory _dayStakeSharesTotal, uint256[] memory _dayPayoutTotal, uint256[] memory _dayDividends)	
    {	
        require(beginDay < endDay && endDay <= globals.dailyDataCount, "CSNE: range invalid");	
        _dayStakeSharesTotal = new uint256[](endDay - beginDay);	
        _dayPayoutTotal = new uint256[](endDay - beginDay);	
        _dayDividends = new uint256[](endDay - beginDay);	
        uint256 src = beginDay;	
        uint256 dst = 0;	
        do {	
            _dayStakeSharesTotal[dst] = uint256(dailyData[src].dayStakeSharesTotal);	
            _dayPayoutTotal[dst++] = uint256(dailyData[src].dayPayoutTotal);	
            _dayDividends[dst++] = dailyData[src].dayDividends;	
        } while (++src < endDay);	
        return (_dayStakeSharesTotal, _dayPayoutTotal, _dayDividends);	
    }	
    /**	
     * @dev PUBLIC FACING: External helper to return most global info with a single call.	
     * Ugly implementation due to limitations of the standard ABI encoder.	
     * @return Fixed array of values	
     */	
    function globalInfo()	
        external	
        view	
        returns (uint256[10] memory)	
    {	
        return [	
            globals.lockedSunsTotal,	
            globals.nextStakeSharesTotal,	
            globals.shareRate,	
            globals.stakePenaltyTotal,	
            globals.dailyDataCount,	
            globals.stakeSharesTotal,	
            globals.latestStakeId,	
            block.timestamp,	
            totalSupply(),	
            xfLobby[_currentDay()]	
        ];	
    }	
    /**	
     * @dev PUBLIC FACING: ERC20 totalSupply() is the circulating supply and does not include any	
     * staked Suns. allocatedSupply() includes both.	
     * @return Allocated Supply in Suns	
     */	
    function allocatedSupply()	
        external	
        view	
        returns (uint256)	
    {	
        return totalSupply() + globals.lockedSunsTotal;	
    }	
    /**	
     * @dev PUBLIC FACING: External helper for the current day number since launch time	
     * @return Current day number (zero-based)	
     */	
    function currentDay()	
        external	
        view	
        returns (uint256)	
    {	
        return _currentDay();	
    }	
    function _currentDay()	
        internal	
        view	
        returns (uint256)	
    {	
        if (block.timestamp < LAUNCH_TIME){	
             return 0;	
        }else{	
             return (block.timestamp - LAUNCH_TIME) / 1 days;	
        }	
    }	
    function _dailyDataUpdateAuto(GlobalsCache memory g)	
        internal	
    {	
        _dailyDataUpdate(g, g._currentDay, true);	
    }	
    function _globalsLoad(GlobalsCache memory g, GlobalsCache memory gSnapshot)	
        internal	
        view	
    {	
        g._lockedSunsTotal = globals.lockedSunsTotal;	
        g._nextStakeSharesTotal = globals.nextStakeSharesTotal;	
        g._shareRate = globals.shareRate;	
        g._stakePenaltyTotal = globals.stakePenaltyTotal;	
        g._dailyDataCount = globals.dailyDataCount;	
        g._stakeSharesTotal = globals.stakeSharesTotal;	
        g._latestStakeId = globals.latestStakeId;	
        g._currentDay = _currentDay();	
        _globalsCacheSnapshot(g, gSnapshot);	
    }	
    function _globalsCacheSnapshot(GlobalsCache memory g, GlobalsCache memory gSnapshot)	
        internal	
        pure	
    {	
        gSnapshot._lockedSunsTotal = g._lockedSunsTotal;	
        gSnapshot._nextStakeSharesTotal = g._nextStakeSharesTotal;	
        gSnapshot._shareRate = g._shareRate;	
        gSnapshot._stakePenaltyTotal = g._stakePenaltyTotal;	
        gSnapshot._dailyDataCount = g._dailyDataCount;	
        gSnapshot._stakeSharesTotal = g._stakeSharesTotal;	
        gSnapshot._latestStakeId = g._latestStakeId;	
    }	
    function _globalsSync(GlobalsCache memory g, GlobalsCache memory gSnapshot)	
        internal	
    {	
        if (g._lockedSunsTotal != gSnapshot._lockedSunsTotal	
            || g._nextStakeSharesTotal != gSnapshot._nextStakeSharesTotal	
            || g._shareRate != gSnapshot._shareRate	
            || g._stakePenaltyTotal != gSnapshot._stakePenaltyTotal) {	
            globals.lockedSunsTotal = uint72(g._lockedSunsTotal);	
            globals.nextStakeSharesTotal = uint72(g._nextStakeSharesTotal);	
            globals.shareRate = uint40(g._shareRate);	
            globals.stakePenaltyTotal = uint72(g._stakePenaltyTotal);	
        }	
        if (g._dailyDataCount != gSnapshot._dailyDataCount	
            || g._stakeSharesTotal != gSnapshot._stakeSharesTotal	
            || g._latestStakeId != gSnapshot._latestStakeId) {	
            globals.dailyDataCount = uint16(g._dailyDataCount);	
            globals.stakeSharesTotal = uint72(g._stakeSharesTotal);	
            globals.latestStakeId = g._latestStakeId;	
        }	
    }	
    function _stakeLoad(StakeStore storage stRef, uint40 stakeIdParam, StakeCache memory st)	
        internal	
        view	
    {	
        /* Ensure caller's stakeIndex is still current */	
        require(stakeIdParam == stRef.stakeId, "CSNE: stakeIdParam not in stake");	
        st._stakeId = stRef.stakeId;	
        st._stakedSuns = stRef.stakedSuns;	
        st._stakeShares = stRef.stakeShares;	
        st._lockedDay = stRef.lockedDay;	
        st._stakedDays = stRef.stakedDays;	
        st._unlockedDay = stRef.unlockedDay;	
    }	
    function _stakeUpdate(StakeStore storage stRef, StakeCache memory st)	
        internal	
    {	
        stRef.stakeId = st._stakeId;	
        stRef.stakedSuns = uint72(st._stakedSuns);	
        stRef.stakeShares = uint72(st._stakeShares);	
        stRef.lockedDay = uint16(st._lockedDay);	
        stRef.stakedDays = uint16(st._stakedDays);	
        stRef.unlockedDay = uint16(st._unlockedDay);	
    }	
    function _stakeAdd(	
        StakeStore[] storage stakeListRef,	
        uint40 newStakeId,	
        uint256 newStakedSuns,	
        uint256 newStakeShares,	
        uint256 newLockedDay,	
        uint256 newStakedDays	
    )	
        internal	
    {	
        stakeListRef.push(	
            StakeStore(	
                newStakeId,	
                uint72(newStakedSuns),	
                uint72(newStakeShares),	
                uint16(newLockedDay),	
                uint16(newStakedDays),	
                uint16(0) // unlockedDay	
            )	
        );	
    }	
    /**	
     * @dev Efficiently delete from an unordered array by moving the last element	
     * to the "hole" and reducing the array length. Can change the order of the list	
     * and invalidate previously held indexes.	
     * @notice stakeListRef length and stakeIndex are already ensured valid in stakeEnd()	
     * @param stakeListRef Reference to stakeLists[stakerAddr] array in storage	
     * @param stakeIndex Index of the element to delete	
     */	
    function _stakeRemove(StakeStore[] storage stakeListRef, uint256 stakeIndex)	
        internal	
    {	
        uint256 lastIndex = stakeListRef.length - 1;	
        /* Skip the copy if element to be removed is already the last element */	
        if (stakeIndex != lastIndex) {	
            /* Copy last element to the requested element's "hole" */	
            stakeListRef[stakeIndex] = stakeListRef[lastIndex];	
        }	
        /*	
            Reduce the array length now that the array is contiguous.	
            Surprisingly, 'pop()' uses less gas than 'stakeListRef.length = lastIndex'	
        */	
        stakeListRef.pop();	
    }	
    /**	
     * @dev Estimate the stake payout for an incomplete day	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param day Day to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _estimatePayoutRewardsDay(GlobalsCache memory g, uint256 stakeSharesParam, uint256 day)	
        internal	
        view	
        returns (uint256 payout)	
    {	
        /* Prevent updating state for this estimation */	
        GlobalsCache memory gTmp;	
        _globalsCacheSnapshot(g, gTmp);	
        DailyRoundState memory rs;	
        rs._allocSupplyCached = totalSupply() + g._lockedSunsTotal;	
        _dailyRoundCalc(gTmp, rs, day);	
        /* Stake is no longer locked so it must be added to total as if it were */	
        gTmp._stakeSharesTotal += stakeSharesParam;	
        payout = rs._payoutTotal * stakeSharesParam / gTmp._stakeSharesTotal;	
        return payout;	
    }	
    function _dailyRoundCalc(GlobalsCache memory g, DailyRoundState memory rs, uint256 day)	
        private	
        view	
    
        {	
        rs._payoutTotal = (rs._allocSupplyCached * 50000 / 68854153);	
        if (g._stakePenaltyTotal != 0) {	
            rs._payoutTotal += g._stakePenaltyTotal;	
            g._stakePenaltyTotal = 0;	
        }	
    }	
    function _dailyRoundCalcAndStore(GlobalsCache memory g, DailyRoundState memory rs, uint256 day)	
        private	
    {	
        _dailyRoundCalc(g, rs, day);	
        dailyData[day].dayPayoutTotal = uint72(rs._payoutTotal);	
        dailyData[day].dayDividends = xfLobby[day];	
        dailyData[day].dayStakeSharesTotal = uint72(g._stakeSharesTotal);	
    }	
    function _dailyDataUpdate(GlobalsCache memory g, uint256 beforeDay, bool isAutoUpdate)	
        private	
    {	
        if (g._dailyDataCount >= beforeDay) {	
            /* Already up-to-date */	
            return;	
        }	
        DailyRoundState memory rs;	
        rs._allocSupplyCached = totalSupply() + g._lockedSunsTotal;	
        uint256 day = g._dailyDataCount;	
        _dailyRoundCalcAndStore(g, rs, day);	
        /* Stakes started during this day are added to the total the next day */	
        if (g._nextStakeSharesTotal != 0) {	
            g._stakeSharesTotal += g._nextStakeSharesTotal;	
            g._nextStakeSharesTotal = 0;	
        }	
        while (++day < beforeDay) {	
            _dailyRoundCalcAndStore(g, rs, day);	
        }	
        emit DailyDataUpdate(	
            msg.sender,	
            block.timestamp,	
            g._dailyDataCount, 	
            day	
        );	
        	
        g._dailyDataCount = day;	
    }	
} | 
	_stakeRemove | 
	function _stakeRemove(StakeStore[] storage stakeListRef, uint256 stakeIndex)	
    internal	
{	
    uint256 lastIndex = stakeListRef.length - 1;	
    /* Skip the copy if element to be removed is already the last element */	
    if (stakeIndex != lastIndex) {	
        /* Copy last element to the requested element's "hole" */	
        stakeListRef[stakeIndex] = stakeListRef[lastIndex];	
    }	
    /*	
        Reduce the array length now that the array is contiguous.	
        Surprisingly, 'pop()' uses less gas than 'stakeListRef.length = lastIndex'	
    */	
    stakeListRef.pop();	
}	
 | 
	/**	
 * @dev Efficiently delete from an unordered array by moving the last element	
 * to the "hole" and reducing the array length. Can change the order of the list	
 * and invalidate previously held indexes.	
 * @notice stakeListRef length and stakeIndex are already ensured valid in stakeEnd()	
 * @param stakeListRef Reference to stakeLists[stakerAddr] array in storage	
 * @param stakeIndex Index of the element to delete	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    14966,
    15629
  ]
} | 4,607 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	GlobalsAndUtility | 
	contract GlobalsAndUtility is ERC20 {
    /*  XfLobbyEnter
    */
    event XfLobbyEnter(
        uint256 timestamp,
        uint256 enterDay,
        uint256 indexed entryIndex,
        uint256 indexed rawAmount
    );
    /*  XfLobbyExit 
    */
    event XfLobbyExit(
        uint256 timestamp,
        uint256 enterDay,
        uint256 indexed entryIndex,
        uint256 indexed xfAmount,
        address indexed referrerAddr
    );
    /*  DailyDataUpdate
    */
    event DailyDataUpdate(
        address indexed updaterAddr,
        uint256 timestamp,
        uint256 beginDay,
        uint256 endDay
    );
    /*  StakeStart
    */
    event StakeStart(
        uint40 indexed stakeId,
        address indexed stakerAddr,
        uint256 stakedGuns,
        uint256 stakeShares,
        uint256 stakedDays
    );
    
    /*  StakeGoodAccounting
    */
    event StakeGoodAccounting(
        uint40 indexed stakeId,
        address indexed stakerAddr,
        address indexed senderAddr,
        uint256 stakedGuns,
        uint256 stakeShares,
        uint256 payout,
        uint256 penalty
    );
    /*  StakeEnd 
    */
    event StakeEnd(
        uint40 indexed stakeId,
        uint40 prevUnlocked,
        address indexed stakerAddr,
        uint256 lockedDay,
        uint256 servedDays,
        uint256 stakedGuns,
        uint256 stakeShares,
        uint256 dividends,
        uint256 payout,
        uint256 penalty,
        uint256 stakeReturn
    );
    /*  ShareRateChange 
    */
    event ShareRateChange(
        uint40 indexed stakeId,
        uint256 timestamp,
        uint256 newShareRate
    );
    /* 	CSN allocation share address
	*	Used for 5% drip into CSN auction
	*	95% of the first 2 days public auction will be redistributed over the next 30 days to balance auction lobby healthy.
	*/
    address payable internal constant FLUSH_ADDR = 0xcE3D57d817dC3B83899907BFec99C7EF2E2AF35d;
    uint8 internal LAST_FLUSHED_DAY = 1;
    /* ERC20 constants */
    string public constant name = "Community Staking Network in ETH";
    string public constant symbol = "CSNE";
    uint8 public constant decimals = 8;
    /* Suns per Satoshi = 10,000 * 1e8 / 1e8 = 1e4 */
    uint256 private constant SUNS_PER_DIV = 10 ** uint256(decimals); // 1e8
    /* Time of contract launch (Dec 7th, 00:00:00 UTC, Auction Day 1 Starts Dec 8th, 00:00:00 UTC) */
    uint256 internal constant LAUNCH_TIME = 1607299200;
    /* Start of claim phase */
    uint256 internal constant PRE_CLAIM_DAYS = 1;
    /* reduce amount of tokens to 2500000 */
    uint256 internal constant CLAIM_STARTING_AMOUNT = 2500000 * (10 ** 8);
    /* reduce amount of tokens to 1000000 */
    uint256 internal constant CLAIM_LOWEST_AMOUNT = 1000000 * (10 ** 8);
    uint256 internal constant CLAIM_PHASE_START_DAY = PRE_CLAIM_DAYS;
    /* Number of words to hold 1 bit for each transform lobby day */
    uint256 internal constant XF_LOBBY_DAY_WORDS = ((1 + (50 * 7)) + 255) >> 8;
    /* Stake timing parameters */
    uint256 internal constant MIN_STAKE_DAYS = 1;
    uint256 internal constant MAX_STAKE_DAYS = 30; //1 month
    uint256 internal constant EARLY_PENALTY_MIN_DAYS = 90;
    uint256 private constant LATE_PENALTY_GRACE_WEEKS = 2;
    uint256 internal constant LATE_PENALTY_GRACE_DAYS = LATE_PENALTY_GRACE_WEEKS * 7;
    uint256 private constant LATE_PENALTY_SCALE_WEEKS = 100;
    uint256 internal constant LATE_PENALTY_SCALE_DAYS = LATE_PENALTY_SCALE_WEEKS * 7;
    /* Stake shares Longer Pays Better bonus constants used by _stakeStartBonusGuns() */
    uint256 private constant LPB_BONUS_PERCENT = 20;
    uint256 private constant LPB_BONUS_MAX_PERCENT = 200;
    uint256 internal constant LPB = 364 * 100 / LPB_BONUS_PERCENT;
    uint256 internal constant LPB_MAX_DAYS = LPB * LPB_BONUS_MAX_PERCENT / 100;
    uint256 private constant BPB_BONUS_PERCENT = 10;
    uint256 private constant BPB_MAX_DIV = 7 * 1e6;
    uint256 internal constant BPB_MAX_SUNS = BPB_MAX_DIV * SUNS_PER_DIV;
    uint256 internal constant BPB = BPB_MAX_SUNS * 100 / BPB_BONUS_PERCENT;
    /* Share rate is scaled to increase precision */
    uint256 internal constant SHARE_RATE_SCALE = 1e5;	
    /* Share rate max (after scaling) */	
    uint256 internal constant SHARE_RATE_UINT_SIZE = 40;	
    uint256 internal constant SHARE_RATE_MAX = (1 << SHARE_RATE_UINT_SIZE) - 1;	
    /* weekly staking bonus */	
    uint8 internal constant BONUS_DAY_SCALE = 2;	
    /* Globals expanded for memory (except _latestStakeId) and compact for storage */	
    struct GlobalsCache {	
        uint256 _lockedSunsTotal;	
        uint256 _nextStakeSharesTotal;	
        uint256 _shareRate;	
        uint256 _stakePenaltyTotal;	
        uint256 _dailyDataCount;	
        uint256 _stakeSharesTotal;	
        uint40 _latestStakeId;	
        uint256 _currentDay;	
    }	
    struct GlobalsStore {	
        uint72 lockedSunsTotal;	
        uint72 nextStakeSharesTotal;	
        uint40 shareRate;	
        uint72 stakePenaltyTotal;	
        uint16 dailyDataCount;	
        uint72 stakeSharesTotal;	
        uint40 latestStakeId;	
    }	
    GlobalsStore public globals;	
    /* Daily data */	
    struct DailyDataStore {	
        uint72 dayPayoutTotal;	
        uint256 dayDividends;	
        uint72 dayStakeSharesTotal;	
    }	
    mapping(uint256 => DailyDataStore) public dailyData;	
    /* Stake expanded for memory (except _stakeId) and compact for storage */	
    struct StakeCache {	
        uint40 _stakeId;	
        uint256 _stakedSuns;	
        uint256 _stakeShares;	
        uint256 _lockedDay;	
        uint256 _stakedDays;	
        uint256 _unlockedDay;	
    }	
    struct StakeStore {	
        uint40 stakeId;	
        uint72 stakedSuns;	
        uint72 stakeShares;	
        uint16 lockedDay;	
        uint16 stakedDays;	
        uint16 unlockedDay;	
    }	
    mapping(address => StakeStore[]) public stakeLists;	
    /* Temporary state for calculating daily rounds */	
    struct DailyRoundState {	
        uint256 _allocSupplyCached;	
        uint256 _payoutTotal;	
    }	
    struct XfLobbyEntryStore {	
        uint96 rawAmount;	
        address referrerAddr;	
    }	
    struct XfLobbyQueueStore {	
        uint40 headIndex;	
        uint40 tailIndex;	
        mapping(uint256 => XfLobbyEntryStore) entries;	
    }	
    mapping(uint256 => uint256) public xfLobby;	
    mapping(uint256 => mapping(address => XfLobbyQueueStore)) public xfLobbyMembers;	
    /**	
     * @dev PUBLIC FACING: Optionally update daily data for a smaller	
     * range to reduce gas cost for a subsequent operation	
     * @param beforeDay Only update days before this day number (optional; 0 for current day)	
     */	
    function dailyDataUpdate(uint256 beforeDay)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* Skip pre-claim period */	
        require(g._currentDay > CLAIM_PHASE_START_DAY, "CSNE: Too early");	
        if (beforeDay != 0) {	
            require(beforeDay <= g._currentDay, "CSNE: beforeDay cannot be in the future");	
            _dailyDataUpdate(g, beforeDay, false);	
        } else {	
            /* Default to updating before current day */	
            _dailyDataUpdate(g, g._currentDay, false);	
        }	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: External helper to return multiple values of daily data with	
     * a single call.	
     * @param endDay Last day (non-inclusive) of data range	
     * @param beginDay First day of data range	
     * @return array of day stake shares total	
     * @return array of day payout total	
     */	
    function dailyDataRange(uint256 beginDay, uint256 endDay)	
        external	
        view	
        returns (uint256[] memory _dayStakeSharesTotal, uint256[] memory _dayPayoutTotal, uint256[] memory _dayDividends)	
    {	
        require(beginDay < endDay && endDay <= globals.dailyDataCount, "CSNE: range invalid");	
        _dayStakeSharesTotal = new uint256[](endDay - beginDay);	
        _dayPayoutTotal = new uint256[](endDay - beginDay);	
        _dayDividends = new uint256[](endDay - beginDay);	
        uint256 src = beginDay;	
        uint256 dst = 0;	
        do {	
            _dayStakeSharesTotal[dst] = uint256(dailyData[src].dayStakeSharesTotal);	
            _dayPayoutTotal[dst++] = uint256(dailyData[src].dayPayoutTotal);	
            _dayDividends[dst++] = dailyData[src].dayDividends;	
        } while (++src < endDay);	
        return (_dayStakeSharesTotal, _dayPayoutTotal, _dayDividends);	
    }	
    /**	
     * @dev PUBLIC FACING: External helper to return most global info with a single call.	
     * Ugly implementation due to limitations of the standard ABI encoder.	
     * @return Fixed array of values	
     */	
    function globalInfo()	
        external	
        view	
        returns (uint256[10] memory)	
    {	
        return [	
            globals.lockedSunsTotal,	
            globals.nextStakeSharesTotal,	
            globals.shareRate,	
            globals.stakePenaltyTotal,	
            globals.dailyDataCount,	
            globals.stakeSharesTotal,	
            globals.latestStakeId,	
            block.timestamp,	
            totalSupply(),	
            xfLobby[_currentDay()]	
        ];	
    }	
    /**	
     * @dev PUBLIC FACING: ERC20 totalSupply() is the circulating supply and does not include any	
     * staked Suns. allocatedSupply() includes both.	
     * @return Allocated Supply in Suns	
     */	
    function allocatedSupply()	
        external	
        view	
        returns (uint256)	
    {	
        return totalSupply() + globals.lockedSunsTotal;	
    }	
    /**	
     * @dev PUBLIC FACING: External helper for the current day number since launch time	
     * @return Current day number (zero-based)	
     */	
    function currentDay()	
        external	
        view	
        returns (uint256)	
    {	
        return _currentDay();	
    }	
    function _currentDay()	
        internal	
        view	
        returns (uint256)	
    {	
        if (block.timestamp < LAUNCH_TIME){	
             return 0;	
        }else{	
             return (block.timestamp - LAUNCH_TIME) / 1 days;	
        }	
    }	
    function _dailyDataUpdateAuto(GlobalsCache memory g)	
        internal	
    {	
        _dailyDataUpdate(g, g._currentDay, true);	
    }	
    function _globalsLoad(GlobalsCache memory g, GlobalsCache memory gSnapshot)	
        internal	
        view	
    {	
        g._lockedSunsTotal = globals.lockedSunsTotal;	
        g._nextStakeSharesTotal = globals.nextStakeSharesTotal;	
        g._shareRate = globals.shareRate;	
        g._stakePenaltyTotal = globals.stakePenaltyTotal;	
        g._dailyDataCount = globals.dailyDataCount;	
        g._stakeSharesTotal = globals.stakeSharesTotal;	
        g._latestStakeId = globals.latestStakeId;	
        g._currentDay = _currentDay();	
        _globalsCacheSnapshot(g, gSnapshot);	
    }	
    function _globalsCacheSnapshot(GlobalsCache memory g, GlobalsCache memory gSnapshot)	
        internal	
        pure	
    {	
        gSnapshot._lockedSunsTotal = g._lockedSunsTotal;	
        gSnapshot._nextStakeSharesTotal = g._nextStakeSharesTotal;	
        gSnapshot._shareRate = g._shareRate;	
        gSnapshot._stakePenaltyTotal = g._stakePenaltyTotal;	
        gSnapshot._dailyDataCount = g._dailyDataCount;	
        gSnapshot._stakeSharesTotal = g._stakeSharesTotal;	
        gSnapshot._latestStakeId = g._latestStakeId;	
    }	
    function _globalsSync(GlobalsCache memory g, GlobalsCache memory gSnapshot)	
        internal	
    {	
        if (g._lockedSunsTotal != gSnapshot._lockedSunsTotal	
            || g._nextStakeSharesTotal != gSnapshot._nextStakeSharesTotal	
            || g._shareRate != gSnapshot._shareRate	
            || g._stakePenaltyTotal != gSnapshot._stakePenaltyTotal) {	
            globals.lockedSunsTotal = uint72(g._lockedSunsTotal);	
            globals.nextStakeSharesTotal = uint72(g._nextStakeSharesTotal);	
            globals.shareRate = uint40(g._shareRate);	
            globals.stakePenaltyTotal = uint72(g._stakePenaltyTotal);	
        }	
        if (g._dailyDataCount != gSnapshot._dailyDataCount	
            || g._stakeSharesTotal != gSnapshot._stakeSharesTotal	
            || g._latestStakeId != gSnapshot._latestStakeId) {	
            globals.dailyDataCount = uint16(g._dailyDataCount);	
            globals.stakeSharesTotal = uint72(g._stakeSharesTotal);	
            globals.latestStakeId = g._latestStakeId;	
        }	
    }	
    function _stakeLoad(StakeStore storage stRef, uint40 stakeIdParam, StakeCache memory st)	
        internal	
        view	
    {	
        /* Ensure caller's stakeIndex is still current */	
        require(stakeIdParam == stRef.stakeId, "CSNE: stakeIdParam not in stake");	
        st._stakeId = stRef.stakeId;	
        st._stakedSuns = stRef.stakedSuns;	
        st._stakeShares = stRef.stakeShares;	
        st._lockedDay = stRef.lockedDay;	
        st._stakedDays = stRef.stakedDays;	
        st._unlockedDay = stRef.unlockedDay;	
    }	
    function _stakeUpdate(StakeStore storage stRef, StakeCache memory st)	
        internal	
    {	
        stRef.stakeId = st._stakeId;	
        stRef.stakedSuns = uint72(st._stakedSuns);	
        stRef.stakeShares = uint72(st._stakeShares);	
        stRef.lockedDay = uint16(st._lockedDay);	
        stRef.stakedDays = uint16(st._stakedDays);	
        stRef.unlockedDay = uint16(st._unlockedDay);	
    }	
    function _stakeAdd(	
        StakeStore[] storage stakeListRef,	
        uint40 newStakeId,	
        uint256 newStakedSuns,	
        uint256 newStakeShares,	
        uint256 newLockedDay,	
        uint256 newStakedDays	
    )	
        internal	
    {	
        stakeListRef.push(	
            StakeStore(	
                newStakeId,	
                uint72(newStakedSuns),	
                uint72(newStakeShares),	
                uint16(newLockedDay),	
                uint16(newStakedDays),	
                uint16(0) // unlockedDay	
            )	
        );	
    }	
    /**	
     * @dev Efficiently delete from an unordered array by moving the last element	
     * to the "hole" and reducing the array length. Can change the order of the list	
     * and invalidate previously held indexes.	
     * @notice stakeListRef length and stakeIndex are already ensured valid in stakeEnd()	
     * @param stakeListRef Reference to stakeLists[stakerAddr] array in storage	
     * @param stakeIndex Index of the element to delete	
     */	
    function _stakeRemove(StakeStore[] storage stakeListRef, uint256 stakeIndex)	
        internal	
    {	
        uint256 lastIndex = stakeListRef.length - 1;	
        /* Skip the copy if element to be removed is already the last element */	
        if (stakeIndex != lastIndex) {	
            /* Copy last element to the requested element's "hole" */	
            stakeListRef[stakeIndex] = stakeListRef[lastIndex];	
        }	
        /*	
            Reduce the array length now that the array is contiguous.	
            Surprisingly, 'pop()' uses less gas than 'stakeListRef.length = lastIndex'	
        */	
        stakeListRef.pop();	
    }	
    /**	
     * @dev Estimate the stake payout for an incomplete day	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param day Day to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _estimatePayoutRewardsDay(GlobalsCache memory g, uint256 stakeSharesParam, uint256 day)	
        internal	
        view	
        returns (uint256 payout)	
    {	
        /* Prevent updating state for this estimation */	
        GlobalsCache memory gTmp;	
        _globalsCacheSnapshot(g, gTmp);	
        DailyRoundState memory rs;	
        rs._allocSupplyCached = totalSupply() + g._lockedSunsTotal;	
        _dailyRoundCalc(gTmp, rs, day);	
        /* Stake is no longer locked so it must be added to total as if it were */	
        gTmp._stakeSharesTotal += stakeSharesParam;	
        payout = rs._payoutTotal * stakeSharesParam / gTmp._stakeSharesTotal;	
        return payout;	
    }	
    function _dailyRoundCalc(GlobalsCache memory g, DailyRoundState memory rs, uint256 day)	
        private	
        view	
    
        {	
        rs._payoutTotal = (rs._allocSupplyCached * 50000 / 68854153);	
        if (g._stakePenaltyTotal != 0) {	
            rs._payoutTotal += g._stakePenaltyTotal;	
            g._stakePenaltyTotal = 0;	
        }	
    }	
    function _dailyRoundCalcAndStore(GlobalsCache memory g, DailyRoundState memory rs, uint256 day)	
        private	
    {	
        _dailyRoundCalc(g, rs, day);	
        dailyData[day].dayPayoutTotal = uint72(rs._payoutTotal);	
        dailyData[day].dayDividends = xfLobby[day];	
        dailyData[day].dayStakeSharesTotal = uint72(g._stakeSharesTotal);	
    }	
    function _dailyDataUpdate(GlobalsCache memory g, uint256 beforeDay, bool isAutoUpdate)	
        private	
    {	
        if (g._dailyDataCount >= beforeDay) {	
            /* Already up-to-date */	
            return;	
        }	
        DailyRoundState memory rs;	
        rs._allocSupplyCached = totalSupply() + g._lockedSunsTotal;	
        uint256 day = g._dailyDataCount;	
        _dailyRoundCalcAndStore(g, rs, day);	
        /* Stakes started during this day are added to the total the next day */	
        if (g._nextStakeSharesTotal != 0) {	
            g._stakeSharesTotal += g._nextStakeSharesTotal;	
            g._nextStakeSharesTotal = 0;	
        }	
        while (++day < beforeDay) {	
            _dailyRoundCalcAndStore(g, rs, day);	
        }	
        emit DailyDataUpdate(	
            msg.sender,	
            block.timestamp,	
            g._dailyDataCount, 	
            day	
        );	
        	
        g._dailyDataCount = day;	
    }	
} | 
	_estimatePayoutRewardsDay | 
	function _estimatePayoutRewardsDay(GlobalsCache memory g, uint256 stakeSharesParam, uint256 day)	
    internal	
    view	
    returns (uint256 payout)	
{	
    /* Prevent updating state for this estimation */	
    GlobalsCache memory gTmp;	
    _globalsCacheSnapshot(g, gTmp);	
    DailyRoundState memory rs;	
    rs._allocSupplyCached = totalSupply() + g._lockedSunsTotal;	
    _dailyRoundCalc(gTmp, rs, day);	
    /* Stake is no longer locked so it must be added to total as if it were */	
    gTmp._stakeSharesTotal += stakeSharesParam;	
    payout = rs._payoutTotal * stakeSharesParam / gTmp._stakeSharesTotal;	
    return payout;	
}	
 | 
	/**	
 * @dev Estimate the stake payout for an incomplete day	
 * @param g Cache of stored globals	
 * @param stakeSharesParam Param from stake to calculate bonuses for	
 * @param day Day to calculate bonuses for	
 * @return Payout in Suns	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    15910,
    16627
  ]
} | 4,608 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	StakeableToken | 
	contract StakeableToken is GlobalsAndUtility {	
    /**	
     * @dev PUBLIC FACING: Open a stake.	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function stakeStart(uint256 newStakedSuns, uint256 newStakedDays)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* Enforce the minimum stake time */	
        require(newStakedDays >= MIN_STAKE_DAYS, "CSNE: newStakedDays lower than minimum");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        _stakeStart(g, newStakedSuns, newStakedDays);	
        /* Remove staked Suns from balance of staker */	
        _burn(msg.sender, newStakedSuns);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Unlocks a completed stake, distributing the proceeds of any penalty	
     * immediately. The staker must still call stakeEnd() to retrieve their stake return (if any).	
     * @param stakerAddr Address of staker	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeGoodAccounting(address stakerAddr, uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* require() is more informative than the default assert() */	
        require(stakeLists[stakerAddr].length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeLists[stakerAddr].length, "CSNE: stakeIndex invalid");	
        StakeStore storage stRef = stakeLists[stakerAddr][stakeIndex];	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stRef, stakeIdParam, st);	
        /* Stake must have served full term */	
        require(g._currentDay >= st._lockedDay + st._stakedDays, "CSNE: Stake not fully served");	
        /* Stake must still be locked */	
        require(st._unlockedDay == 0, "CSNE: Stake already unlocked");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        /* Unlock the completed stake */	
        _stakeUnlock(g, st);	
        /* stakeReturn & dividends values are unused here */	
        (, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty) = _stakePerformance(	
            g,	
            st,	
            st._stakedDays	
        );	
        emit StakeGoodAccounting(	
            stakeIdParam,	
            stakerAddr,	
            msg.sender,	
            st._stakedSuns,	
            st._stakeShares,	
            payout,	
            penalty	
        );	
        if (cappedPenalty != 0) {	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* st._unlockedDay has changed */	
        _stakeUpdate(stRef, st);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Closes a stake. The order of the stake list can change so	
     * a stake id is used to reject stale indexes.	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeEnd(uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        StakeStore[] storage stakeListRef = stakeLists[msg.sender];	
        /* require() is more informative than the default assert() */	
        require(stakeListRef.length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeListRef.length, "CSNE: stakeIndex invalid");	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stakeListRef[stakeIndex], stakeIdParam, st);	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        uint256 servedDays = 0;	
        bool prevUnlocked = (st._unlockedDay != 0);	
        uint256 stakeReturn;	
        uint256 payout = 0;	
        uint256 dividends = 0;	
        uint256 penalty = 0;	
        uint256 cappedPenalty = 0;	
        if (g._currentDay >= st._lockedDay) {	
            if (prevUnlocked) {	
                /* Previously unlocked in stakeGoodAccounting(), so must have served full term */	
                servedDays = st._stakedDays;	
            } else {	
                _stakeUnlock(g, st);	
                servedDays = g._currentDay - st._lockedDay;	
                if (servedDays > st._stakedDays) {	
                    servedDays = st._stakedDays;	
                }	
            }	
            (stakeReturn, payout, dividends, penalty, cappedPenalty) = _stakePerformance(g, st, servedDays);	
            msg.sender.transfer(dividends);	
        } else {	
            /* Stake hasn't been added to the total yet, so no penalties or rewards apply */	
            g._nextStakeSharesTotal -= st._stakeShares;	
            stakeReturn = st._stakedSuns;	
        }	
        emit StakeEnd(	
            stakeIdParam, 	
            prevUnlocked ? 1 : 0,	
            msg.sender,	
            st._lockedDay,	
            servedDays, 	
            st._stakedSuns, 	
            st._stakeShares, 	
            dividends,	
            payout, 	
            penalty,	
            stakeReturn	
        );	
        if (cappedPenalty != 0 && !prevUnlocked) {	
            /* Split penalty proceeds only if not previously unlocked by stakeGoodAccounting() */	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* Pay the stake return, if any, to the staker */	
        if (stakeReturn != 0) {	
            _mint(msg.sender, stakeReturn);	
            /* Update the share rate if necessary */	
            _shareRateUpdate(g, st, stakeReturn);	
        }	
        g._lockedSunsTotal -= st._stakedSuns;	
        _stakeRemove(stakeListRef, stakeIndex);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the current stake count for a staker address	
     * @param stakerAddr Address of staker	
     */	
    function stakeCount(address stakerAddr)	
        external	
        view	
        returns (uint256)	
    {	
        return stakeLists[stakerAddr].length;	
    }	
    /**	
     * @dev Open a stake.	
     * @param g Cache of stored globals	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStart(	
        GlobalsCache memory g,	
        uint256 newStakedSuns,	
        uint256 newStakedDays	
    )	
        internal	
    {	
        /* Enforce the maximum stake time */	
        require(newStakedDays <= MAX_STAKE_DAYS, "CSNE: newStakedDays higher than maximum");	
        uint256 bonusSuns = _stakeStartBonusSuns(newStakedSuns, newStakedDays);	
        uint256 newStakeShares = (newStakedSuns + bonusSuns) * SHARE_RATE_SCALE / g._shareRate;	
        /* Ensure newStakedSuns is enough for at least one stake share */	
        require(newStakeShares != 0, "CSNE: newStakedSuns must be at least minimum shareRate");	
        /*	
            The stakeStart timestamp will always be part-way through the current	
            day, so it needs to be rounded-up to the next day to ensure all	
            stakes align with the same fixed calendar days. The current day is	
            already rounded-down, so rounded-up is current day + 1.	
        */	
        uint256 newLockedDay = g._currentDay + 1;	
        /* Create Stake */	
        uint40 newStakeId = ++g._latestStakeId;	
        _stakeAdd(	
            stakeLists[msg.sender],	
            newStakeId,	
            newStakedSuns,	
            newStakeShares,	
            newLockedDay,	
            newStakedDays	
        );	
        emit StakeStart(	
            newStakeId, 	
            msg.sender,	
            newStakedSuns, 	
            newStakeShares, 	
            newStakedDays	
        );	
        /* Stake is added to total in the next round, not the current round */	
        g._nextStakeSharesTotal += newStakeShares;	
        /* Track total staked Suns for inflation calculations */	
        g._lockedSunsTotal += newStakedSuns;	
    }	
    /**	
     * @dev Calculates total stake payout including rewards for a multi-day range	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutRewards(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        uint256 counter;	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            dayPayout = dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal;	
            if (counter < 4) {	
                counter++;	
            } 	
            /* Eligible to receive bonus */	
            else {	
                dayPayout = (dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal) * BONUS_DAY_SCALE;	
                counter = 0;	
            }	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculates user dividends	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutDividendsReward(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            /* user's share of 95% of the day's dividends */	
            dayPayout += ((dailyData[day].dayDividends * 95) / 100) * stakeSharesParam	
            / dailyData[day].dayStakeSharesTotal;	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculate bonus Suns for a new stake, if any	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStartBonusSuns(uint256 newStakedSuns, uint256 newStakedDays)	
        private	
        pure	
        returns (uint256 bonusSuns)	
    {	
       
        uint256 cappedExtraDays = 0;	
        /* Must be more than 1 day for Longer-Pays-Better */	
        if (newStakedDays > 1) {	
            cappedExtraDays = newStakedDays <= LPB_MAX_DAYS ? newStakedDays - 1 : LPB_MAX_DAYS;	
        }	
        uint256 cappedStakedSuns = newStakedSuns <= BPB_MAX_SUNS	
            ? newStakedSuns	
            : BPB_MAX_SUNS;	
        bonusSuns = cappedExtraDays * BPB + cappedStakedSuns * LPB;	
        bonusSuns = newStakedSuns * bonusSuns / (LPB * BPB);	
        return bonusSuns;	
    }	
    function _stakeUnlock(GlobalsCache memory g, StakeCache memory st)	
        private	
        pure	
    {	
        g._stakeSharesTotal -= st._stakeShares;	
        st._unlockedDay = g._currentDay;	
    }	
    function _stakePerformance(GlobalsCache memory g, StakeCache memory st, uint256 servedDays)	
        private	
        view	
        returns (uint256 stakeReturn, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty)	
    {	
        if (servedDays < st._stakedDays) {	
            (payout, penalty) = _calcPayoutAndEarlyPenalty(	
                g,	
                st._lockedDay,	
                st._stakedDays,	
                servedDays,	
                st._stakeShares	
            );	
            stakeReturn = st._stakedSuns + payout;	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
        } else {	
            // servedDays must == stakedDays here	
            payout = _calcPayoutRewards(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            stakeReturn = st._stakedSuns + payout;	
            penalty = _calcLatePenalty(st._lockedDay, st._stakedDays, st._unlockedDay, stakeReturn);	
        }	
        if (penalty != 0) {	
            if (penalty > stakeReturn) {	
                /* Cannot have a negative stake return */	
                cappedPenalty = stakeReturn;	
                stakeReturn = 0;	
            } else {	
                /* Remove penalty from the stake return */	
                cappedPenalty = penalty;	
                stakeReturn -= cappedPenalty;	
            }	
        }	
        return (stakeReturn, payout, dividends, penalty, cappedPenalty);	
    }	
    function _calcPayoutAndEarlyPenalty(	
        GlobalsCache memory g,	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 servedDays,	
        uint256 stakeSharesParam	
    )	
        private	
        view	
        returns (uint256 payout, uint256 penalty)	
    {	
        uint256 servedEndDay = lockedDayParam + servedDays;	
        /* 50% of stakedDays (rounded up) with a minimum applied */	
        uint256 penaltyDays = (stakedDaysParam + 1) / 2;	
        if (penaltyDays < EARLY_PENALTY_MIN_DAYS) {	
            penaltyDays = EARLY_PENALTY_MIN_DAYS;	
        }	
        if (servedDays == 0) {	
            /* Fill penalty days with the estimated average payout */	
            uint256 expected = _estimatePayoutRewardsDay(g, stakeSharesParam, lockedDayParam);	
            penalty = expected * penaltyDays;	
            return (payout, penalty); // Actual payout was 0	
        }	
        if (penaltyDays < servedDays) {	
            /*	
                Simplified explanation of intervals where end-day is non-inclusive:	
                penalty:    [lockedDay  ...  penaltyEndDay)	
                delta:                      [penaltyEndDay  ...  servedEndDay)	
                payout:     [lockedDay  .......................  servedEndDay)	
            */	
            uint256 penaltyEndDay = lockedDayParam + penaltyDays;	
            penalty = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, penaltyEndDay);	
            uint256 delta = _calcPayoutRewards(g, stakeSharesParam, penaltyEndDay, servedEndDay);	
            payout = penalty + delta;	
            return (payout, penalty);	
        }	
        /* penaltyDays >= servedDays  */	
        payout = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, servedEndDay);	
        if (penaltyDays == servedDays) {	
            penalty = payout;	
        } else {	
            /*	
                (penaltyDays > servedDays) means not enough days served, so fill the	
                penalty days with the average payout from only the days that were served.	
            */	
            penalty = payout * penaltyDays / servedDays;	
        }	
        return (payout, penalty);	
    }	
    function _calcLatePenalty(	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 unlockedDayParam,	
        uint256 rawStakeReturn	
    )	
        private	
        pure	
        returns (uint256)	
    {	
        /* Allow grace time before penalties accrue */	
        uint256 maxUnlockedDay = lockedDayParam + stakedDaysParam + LATE_PENALTY_GRACE_DAYS;	
        if (unlockedDayParam <= maxUnlockedDay) {	
            return 0;	
        }	
        /* Calculate penalty as a percentage of stake return based on time */	
        return rawStakeReturn * (unlockedDayParam - maxUnlockedDay) / LATE_PENALTY_SCALE_DAYS;	
    }	
    function _shareRateUpdate(GlobalsCache memory g, StakeCache memory st, uint256 stakeReturn)	
        private	
    {	
        if (stakeReturn > st._stakedSuns) {	
            /*	
                Calculate the new shareRate that would yield the same number of shares if	
                the user re-staked this stakeReturn, factoring in any bonuses they would	
                receive in stakeStart().	
            */	
            uint256 bonusSuns = _stakeStartBonusSuns(stakeReturn, st._stakedDays);	
            uint256 newShareRate = (stakeReturn + bonusSuns) * SHARE_RATE_SCALE / st._stakeShares;	
            if (newShareRate > SHARE_RATE_MAX) {	
                /*	
                    Realistically this can't happen, but there are contrived theoretical	
                    scenarios that can lead to extreme values of newShareRate, so it is	
                    capped to prevent them anyway.	
                */	
                newShareRate = SHARE_RATE_MAX;	
            }	
            if (newShareRate > g._shareRate) {	
                g._shareRate = newShareRate;	
                emit ShareRateChange(	
                    st._stakeId,	
                    block.timestamp,	
                    newShareRate	
                );	
            }	
        }	
    }	
} | 
	stakeStart | 
	function stakeStart(uint256 newStakedSuns, uint256 newStakedDays)	
    external	
{	
    GlobalsCache memory g;	
    GlobalsCache memory gSnapshot;	
    _globalsLoad(g, gSnapshot);	
    /* Enforce the minimum stake time */	
    require(newStakedDays >= MIN_STAKE_DAYS, "CSNE: newStakedDays lower than minimum");	
    /* Check if log data needs to be updated */	
    _dailyDataUpdateAuto(g);	
    _stakeStart(g, newStakedSuns, newStakedDays);	
    /* Remove staked Suns from balance of staker */	
    _burn(msg.sender, newStakedSuns);	
    _globalsSync(g, gSnapshot);	
}	
 | 
	/**	
 * @dev PUBLIC FACING: Open a stake.	
 * @param newStakedSuns Number of Suns to stake	
 * @param newStakedDays Number of days to stake	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    220,
    864
  ]
} | 4,609 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	StakeableToken | 
	contract StakeableToken is GlobalsAndUtility {	
    /**	
     * @dev PUBLIC FACING: Open a stake.	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function stakeStart(uint256 newStakedSuns, uint256 newStakedDays)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* Enforce the minimum stake time */	
        require(newStakedDays >= MIN_STAKE_DAYS, "CSNE: newStakedDays lower than minimum");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        _stakeStart(g, newStakedSuns, newStakedDays);	
        /* Remove staked Suns from balance of staker */	
        _burn(msg.sender, newStakedSuns);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Unlocks a completed stake, distributing the proceeds of any penalty	
     * immediately. The staker must still call stakeEnd() to retrieve their stake return (if any).	
     * @param stakerAddr Address of staker	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeGoodAccounting(address stakerAddr, uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* require() is more informative than the default assert() */	
        require(stakeLists[stakerAddr].length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeLists[stakerAddr].length, "CSNE: stakeIndex invalid");	
        StakeStore storage stRef = stakeLists[stakerAddr][stakeIndex];	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stRef, stakeIdParam, st);	
        /* Stake must have served full term */	
        require(g._currentDay >= st._lockedDay + st._stakedDays, "CSNE: Stake not fully served");	
        /* Stake must still be locked */	
        require(st._unlockedDay == 0, "CSNE: Stake already unlocked");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        /* Unlock the completed stake */	
        _stakeUnlock(g, st);	
        /* stakeReturn & dividends values are unused here */	
        (, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty) = _stakePerformance(	
            g,	
            st,	
            st._stakedDays	
        );	
        emit StakeGoodAccounting(	
            stakeIdParam,	
            stakerAddr,	
            msg.sender,	
            st._stakedSuns,	
            st._stakeShares,	
            payout,	
            penalty	
        );	
        if (cappedPenalty != 0) {	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* st._unlockedDay has changed */	
        _stakeUpdate(stRef, st);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Closes a stake. The order of the stake list can change so	
     * a stake id is used to reject stale indexes.	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeEnd(uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        StakeStore[] storage stakeListRef = stakeLists[msg.sender];	
        /* require() is more informative than the default assert() */	
        require(stakeListRef.length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeListRef.length, "CSNE: stakeIndex invalid");	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stakeListRef[stakeIndex], stakeIdParam, st);	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        uint256 servedDays = 0;	
        bool prevUnlocked = (st._unlockedDay != 0);	
        uint256 stakeReturn;	
        uint256 payout = 0;	
        uint256 dividends = 0;	
        uint256 penalty = 0;	
        uint256 cappedPenalty = 0;	
        if (g._currentDay >= st._lockedDay) {	
            if (prevUnlocked) {	
                /* Previously unlocked in stakeGoodAccounting(), so must have served full term */	
                servedDays = st._stakedDays;	
            } else {	
                _stakeUnlock(g, st);	
                servedDays = g._currentDay - st._lockedDay;	
                if (servedDays > st._stakedDays) {	
                    servedDays = st._stakedDays;	
                }	
            }	
            (stakeReturn, payout, dividends, penalty, cappedPenalty) = _stakePerformance(g, st, servedDays);	
            msg.sender.transfer(dividends);	
        } else {	
            /* Stake hasn't been added to the total yet, so no penalties or rewards apply */	
            g._nextStakeSharesTotal -= st._stakeShares;	
            stakeReturn = st._stakedSuns;	
        }	
        emit StakeEnd(	
            stakeIdParam, 	
            prevUnlocked ? 1 : 0,	
            msg.sender,	
            st._lockedDay,	
            servedDays, 	
            st._stakedSuns, 	
            st._stakeShares, 	
            dividends,	
            payout, 	
            penalty,	
            stakeReturn	
        );	
        if (cappedPenalty != 0 && !prevUnlocked) {	
            /* Split penalty proceeds only if not previously unlocked by stakeGoodAccounting() */	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* Pay the stake return, if any, to the staker */	
        if (stakeReturn != 0) {	
            _mint(msg.sender, stakeReturn);	
            /* Update the share rate if necessary */	
            _shareRateUpdate(g, st, stakeReturn);	
        }	
        g._lockedSunsTotal -= st._stakedSuns;	
        _stakeRemove(stakeListRef, stakeIndex);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the current stake count for a staker address	
     * @param stakerAddr Address of staker	
     */	
    function stakeCount(address stakerAddr)	
        external	
        view	
        returns (uint256)	
    {	
        return stakeLists[stakerAddr].length;	
    }	
    /**	
     * @dev Open a stake.	
     * @param g Cache of stored globals	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStart(	
        GlobalsCache memory g,	
        uint256 newStakedSuns,	
        uint256 newStakedDays	
    )	
        internal	
    {	
        /* Enforce the maximum stake time */	
        require(newStakedDays <= MAX_STAKE_DAYS, "CSNE: newStakedDays higher than maximum");	
        uint256 bonusSuns = _stakeStartBonusSuns(newStakedSuns, newStakedDays);	
        uint256 newStakeShares = (newStakedSuns + bonusSuns) * SHARE_RATE_SCALE / g._shareRate;	
        /* Ensure newStakedSuns is enough for at least one stake share */	
        require(newStakeShares != 0, "CSNE: newStakedSuns must be at least minimum shareRate");	
        /*	
            The stakeStart timestamp will always be part-way through the current	
            day, so it needs to be rounded-up to the next day to ensure all	
            stakes align with the same fixed calendar days. The current day is	
            already rounded-down, so rounded-up is current day + 1.	
        */	
        uint256 newLockedDay = g._currentDay + 1;	
        /* Create Stake */	
        uint40 newStakeId = ++g._latestStakeId;	
        _stakeAdd(	
            stakeLists[msg.sender],	
            newStakeId,	
            newStakedSuns,	
            newStakeShares,	
            newLockedDay,	
            newStakedDays	
        );	
        emit StakeStart(	
            newStakeId, 	
            msg.sender,	
            newStakedSuns, 	
            newStakeShares, 	
            newStakedDays	
        );	
        /* Stake is added to total in the next round, not the current round */	
        g._nextStakeSharesTotal += newStakeShares;	
        /* Track total staked Suns for inflation calculations */	
        g._lockedSunsTotal += newStakedSuns;	
    }	
    /**	
     * @dev Calculates total stake payout including rewards for a multi-day range	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutRewards(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        uint256 counter;	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            dayPayout = dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal;	
            if (counter < 4) {	
                counter++;	
            } 	
            /* Eligible to receive bonus */	
            else {	
                dayPayout = (dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal) * BONUS_DAY_SCALE;	
                counter = 0;	
            }	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculates user dividends	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutDividendsReward(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            /* user's share of 95% of the day's dividends */	
            dayPayout += ((dailyData[day].dayDividends * 95) / 100) * stakeSharesParam	
            / dailyData[day].dayStakeSharesTotal;	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculate bonus Suns for a new stake, if any	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStartBonusSuns(uint256 newStakedSuns, uint256 newStakedDays)	
        private	
        pure	
        returns (uint256 bonusSuns)	
    {	
       
        uint256 cappedExtraDays = 0;	
        /* Must be more than 1 day for Longer-Pays-Better */	
        if (newStakedDays > 1) {	
            cappedExtraDays = newStakedDays <= LPB_MAX_DAYS ? newStakedDays - 1 : LPB_MAX_DAYS;	
        }	
        uint256 cappedStakedSuns = newStakedSuns <= BPB_MAX_SUNS	
            ? newStakedSuns	
            : BPB_MAX_SUNS;	
        bonusSuns = cappedExtraDays * BPB + cappedStakedSuns * LPB;	
        bonusSuns = newStakedSuns * bonusSuns / (LPB * BPB);	
        return bonusSuns;	
    }	
    function _stakeUnlock(GlobalsCache memory g, StakeCache memory st)	
        private	
        pure	
    {	
        g._stakeSharesTotal -= st._stakeShares;	
        st._unlockedDay = g._currentDay;	
    }	
    function _stakePerformance(GlobalsCache memory g, StakeCache memory st, uint256 servedDays)	
        private	
        view	
        returns (uint256 stakeReturn, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty)	
    {	
        if (servedDays < st._stakedDays) {	
            (payout, penalty) = _calcPayoutAndEarlyPenalty(	
                g,	
                st._lockedDay,	
                st._stakedDays,	
                servedDays,	
                st._stakeShares	
            );	
            stakeReturn = st._stakedSuns + payout;	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
        } else {	
            // servedDays must == stakedDays here	
            payout = _calcPayoutRewards(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            stakeReturn = st._stakedSuns + payout;	
            penalty = _calcLatePenalty(st._lockedDay, st._stakedDays, st._unlockedDay, stakeReturn);	
        }	
        if (penalty != 0) {	
            if (penalty > stakeReturn) {	
                /* Cannot have a negative stake return */	
                cappedPenalty = stakeReturn;	
                stakeReturn = 0;	
            } else {	
                /* Remove penalty from the stake return */	
                cappedPenalty = penalty;	
                stakeReturn -= cappedPenalty;	
            }	
        }	
        return (stakeReturn, payout, dividends, penalty, cappedPenalty);	
    }	
    function _calcPayoutAndEarlyPenalty(	
        GlobalsCache memory g,	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 servedDays,	
        uint256 stakeSharesParam	
    )	
        private	
        view	
        returns (uint256 payout, uint256 penalty)	
    {	
        uint256 servedEndDay = lockedDayParam + servedDays;	
        /* 50% of stakedDays (rounded up) with a minimum applied */	
        uint256 penaltyDays = (stakedDaysParam + 1) / 2;	
        if (penaltyDays < EARLY_PENALTY_MIN_DAYS) {	
            penaltyDays = EARLY_PENALTY_MIN_DAYS;	
        }	
        if (servedDays == 0) {	
            /* Fill penalty days with the estimated average payout */	
            uint256 expected = _estimatePayoutRewardsDay(g, stakeSharesParam, lockedDayParam);	
            penalty = expected * penaltyDays;	
            return (payout, penalty); // Actual payout was 0	
        }	
        if (penaltyDays < servedDays) {	
            /*	
                Simplified explanation of intervals where end-day is non-inclusive:	
                penalty:    [lockedDay  ...  penaltyEndDay)	
                delta:                      [penaltyEndDay  ...  servedEndDay)	
                payout:     [lockedDay  .......................  servedEndDay)	
            */	
            uint256 penaltyEndDay = lockedDayParam + penaltyDays;	
            penalty = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, penaltyEndDay);	
            uint256 delta = _calcPayoutRewards(g, stakeSharesParam, penaltyEndDay, servedEndDay);	
            payout = penalty + delta;	
            return (payout, penalty);	
        }	
        /* penaltyDays >= servedDays  */	
        payout = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, servedEndDay);	
        if (penaltyDays == servedDays) {	
            penalty = payout;	
        } else {	
            /*	
                (penaltyDays > servedDays) means not enough days served, so fill the	
                penalty days with the average payout from only the days that were served.	
            */	
            penalty = payout * penaltyDays / servedDays;	
        }	
        return (payout, penalty);	
    }	
    function _calcLatePenalty(	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 unlockedDayParam,	
        uint256 rawStakeReturn	
    )	
        private	
        pure	
        returns (uint256)	
    {	
        /* Allow grace time before penalties accrue */	
        uint256 maxUnlockedDay = lockedDayParam + stakedDaysParam + LATE_PENALTY_GRACE_DAYS;	
        if (unlockedDayParam <= maxUnlockedDay) {	
            return 0;	
        }	
        /* Calculate penalty as a percentage of stake return based on time */	
        return rawStakeReturn * (unlockedDayParam - maxUnlockedDay) / LATE_PENALTY_SCALE_DAYS;	
    }	
    function _shareRateUpdate(GlobalsCache memory g, StakeCache memory st, uint256 stakeReturn)	
        private	
    {	
        if (stakeReturn > st._stakedSuns) {	
            /*	
                Calculate the new shareRate that would yield the same number of shares if	
                the user re-staked this stakeReturn, factoring in any bonuses they would	
                receive in stakeStart().	
            */	
            uint256 bonusSuns = _stakeStartBonusSuns(stakeReturn, st._stakedDays);	
            uint256 newShareRate = (stakeReturn + bonusSuns) * SHARE_RATE_SCALE / st._stakeShares;	
            if (newShareRate > SHARE_RATE_MAX) {	
                /*	
                    Realistically this can't happen, but there are contrived theoretical	
                    scenarios that can lead to extreme values of newShareRate, so it is	
                    capped to prevent them anyway.	
                */	
                newShareRate = SHARE_RATE_MAX;	
            }	
            if (newShareRate > g._shareRate) {	
                g._shareRate = newShareRate;	
                emit ShareRateChange(	
                    st._stakeId,	
                    block.timestamp,	
                    newShareRate	
                );	
            }	
        }	
    }	
} | 
	stakeGoodAccounting | 
	function stakeGoodAccounting(address stakerAddr, uint256 stakeIndex, uint40 stakeIdParam)	
    external	
{	
    GlobalsCache memory g;	
    GlobalsCache memory gSnapshot;	
    _globalsLoad(g, gSnapshot);	
    /* require() is more informative than the default assert() */	
    require(stakeLists[stakerAddr].length != 0, "CSNE: Empty stake list");	
    require(stakeIndex < stakeLists[stakerAddr].length, "CSNE: stakeIndex invalid");	
    StakeStore storage stRef = stakeLists[stakerAddr][stakeIndex];	
    /* Get stake copy */	
    StakeCache memory st;	
    _stakeLoad(stRef, stakeIdParam, st);	
    /* Stake must have served full term */	
    require(g._currentDay >= st._lockedDay + st._stakedDays, "CSNE: Stake not fully served");	
    /* Stake must still be locked */	
    require(st._unlockedDay == 0, "CSNE: Stake already unlocked");	
    /* Check if log data needs to be updated */	
    _dailyDataUpdateAuto(g);	
    /* Unlock the completed stake */	
    _stakeUnlock(g, st);	
    /* stakeReturn & dividends values are unused here */	
    (, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty) = _stakePerformance(	
        g,	
        st,	
        st._stakedDays	
    );	
    emit StakeGoodAccounting(	
        stakeIdParam,	
        stakerAddr,	
        msg.sender,	
        st._stakedSuns,	
        st._stakeShares,	
        payout,	
        penalty	
    );	
    if (cappedPenalty != 0) {	
        g._stakePenaltyTotal += cappedPenalty;	
    }	
    /* st._unlockedDay has changed */	
    _stakeUpdate(stRef, st);	
    _globalsSync(g, gSnapshot);	
}	
 | 
	/**	
 * @dev PUBLIC FACING: Unlocks a completed stake, distributing the proceeds of any penalty	
 * immediately. The staker must still call stakeEnd() to retrieve their stake return (if any).	
 * @param stakerAddr Address of staker	
 * @param stakeIndex Index of stake within stake list	
 * @param stakeIdParam The stake's id	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    1232,
    3030
  ]
} | 4,610 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	StakeableToken | 
	contract StakeableToken is GlobalsAndUtility {	
    /**	
     * @dev PUBLIC FACING: Open a stake.	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function stakeStart(uint256 newStakedSuns, uint256 newStakedDays)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* Enforce the minimum stake time */	
        require(newStakedDays >= MIN_STAKE_DAYS, "CSNE: newStakedDays lower than minimum");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        _stakeStart(g, newStakedSuns, newStakedDays);	
        /* Remove staked Suns from balance of staker */	
        _burn(msg.sender, newStakedSuns);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Unlocks a completed stake, distributing the proceeds of any penalty	
     * immediately. The staker must still call stakeEnd() to retrieve their stake return (if any).	
     * @param stakerAddr Address of staker	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeGoodAccounting(address stakerAddr, uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* require() is more informative than the default assert() */	
        require(stakeLists[stakerAddr].length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeLists[stakerAddr].length, "CSNE: stakeIndex invalid");	
        StakeStore storage stRef = stakeLists[stakerAddr][stakeIndex];	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stRef, stakeIdParam, st);	
        /* Stake must have served full term */	
        require(g._currentDay >= st._lockedDay + st._stakedDays, "CSNE: Stake not fully served");	
        /* Stake must still be locked */	
        require(st._unlockedDay == 0, "CSNE: Stake already unlocked");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        /* Unlock the completed stake */	
        _stakeUnlock(g, st);	
        /* stakeReturn & dividends values are unused here */	
        (, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty) = _stakePerformance(	
            g,	
            st,	
            st._stakedDays	
        );	
        emit StakeGoodAccounting(	
            stakeIdParam,	
            stakerAddr,	
            msg.sender,	
            st._stakedSuns,	
            st._stakeShares,	
            payout,	
            penalty	
        );	
        if (cappedPenalty != 0) {	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* st._unlockedDay has changed */	
        _stakeUpdate(stRef, st);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Closes a stake. The order of the stake list can change so	
     * a stake id is used to reject stale indexes.	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeEnd(uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        StakeStore[] storage stakeListRef = stakeLists[msg.sender];	
        /* require() is more informative than the default assert() */	
        require(stakeListRef.length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeListRef.length, "CSNE: stakeIndex invalid");	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stakeListRef[stakeIndex], stakeIdParam, st);	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        uint256 servedDays = 0;	
        bool prevUnlocked = (st._unlockedDay != 0);	
        uint256 stakeReturn;	
        uint256 payout = 0;	
        uint256 dividends = 0;	
        uint256 penalty = 0;	
        uint256 cappedPenalty = 0;	
        if (g._currentDay >= st._lockedDay) {	
            if (prevUnlocked) {	
                /* Previously unlocked in stakeGoodAccounting(), so must have served full term */	
                servedDays = st._stakedDays;	
            } else {	
                _stakeUnlock(g, st);	
                servedDays = g._currentDay - st._lockedDay;	
                if (servedDays > st._stakedDays) {	
                    servedDays = st._stakedDays;	
                }	
            }	
            (stakeReturn, payout, dividends, penalty, cappedPenalty) = _stakePerformance(g, st, servedDays);	
            msg.sender.transfer(dividends);	
        } else {	
            /* Stake hasn't been added to the total yet, so no penalties or rewards apply */	
            g._nextStakeSharesTotal -= st._stakeShares;	
            stakeReturn = st._stakedSuns;	
        }	
        emit StakeEnd(	
            stakeIdParam, 	
            prevUnlocked ? 1 : 0,	
            msg.sender,	
            st._lockedDay,	
            servedDays, 	
            st._stakedSuns, 	
            st._stakeShares, 	
            dividends,	
            payout, 	
            penalty,	
            stakeReturn	
        );	
        if (cappedPenalty != 0 && !prevUnlocked) {	
            /* Split penalty proceeds only if not previously unlocked by stakeGoodAccounting() */	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* Pay the stake return, if any, to the staker */	
        if (stakeReturn != 0) {	
            _mint(msg.sender, stakeReturn);	
            /* Update the share rate if necessary */	
            _shareRateUpdate(g, st, stakeReturn);	
        }	
        g._lockedSunsTotal -= st._stakedSuns;	
        _stakeRemove(stakeListRef, stakeIndex);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the current stake count for a staker address	
     * @param stakerAddr Address of staker	
     */	
    function stakeCount(address stakerAddr)	
        external	
        view	
        returns (uint256)	
    {	
        return stakeLists[stakerAddr].length;	
    }	
    /**	
     * @dev Open a stake.	
     * @param g Cache of stored globals	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStart(	
        GlobalsCache memory g,	
        uint256 newStakedSuns,	
        uint256 newStakedDays	
    )	
        internal	
    {	
        /* Enforce the maximum stake time */	
        require(newStakedDays <= MAX_STAKE_DAYS, "CSNE: newStakedDays higher than maximum");	
        uint256 bonusSuns = _stakeStartBonusSuns(newStakedSuns, newStakedDays);	
        uint256 newStakeShares = (newStakedSuns + bonusSuns) * SHARE_RATE_SCALE / g._shareRate;	
        /* Ensure newStakedSuns is enough for at least one stake share */	
        require(newStakeShares != 0, "CSNE: newStakedSuns must be at least minimum shareRate");	
        /*	
            The stakeStart timestamp will always be part-way through the current	
            day, so it needs to be rounded-up to the next day to ensure all	
            stakes align with the same fixed calendar days. The current day is	
            already rounded-down, so rounded-up is current day + 1.	
        */	
        uint256 newLockedDay = g._currentDay + 1;	
        /* Create Stake */	
        uint40 newStakeId = ++g._latestStakeId;	
        _stakeAdd(	
            stakeLists[msg.sender],	
            newStakeId,	
            newStakedSuns,	
            newStakeShares,	
            newLockedDay,	
            newStakedDays	
        );	
        emit StakeStart(	
            newStakeId, 	
            msg.sender,	
            newStakedSuns, 	
            newStakeShares, 	
            newStakedDays	
        );	
        /* Stake is added to total in the next round, not the current round */	
        g._nextStakeSharesTotal += newStakeShares;	
        /* Track total staked Suns for inflation calculations */	
        g._lockedSunsTotal += newStakedSuns;	
    }	
    /**	
     * @dev Calculates total stake payout including rewards for a multi-day range	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutRewards(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        uint256 counter;	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            dayPayout = dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal;	
            if (counter < 4) {	
                counter++;	
            } 	
            /* Eligible to receive bonus */	
            else {	
                dayPayout = (dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal) * BONUS_DAY_SCALE;	
                counter = 0;	
            }	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculates user dividends	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutDividendsReward(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            /* user's share of 95% of the day's dividends */	
            dayPayout += ((dailyData[day].dayDividends * 95) / 100) * stakeSharesParam	
            / dailyData[day].dayStakeSharesTotal;	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculate bonus Suns for a new stake, if any	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStartBonusSuns(uint256 newStakedSuns, uint256 newStakedDays)	
        private	
        pure	
        returns (uint256 bonusSuns)	
    {	
       
        uint256 cappedExtraDays = 0;	
        /* Must be more than 1 day for Longer-Pays-Better */	
        if (newStakedDays > 1) {	
            cappedExtraDays = newStakedDays <= LPB_MAX_DAYS ? newStakedDays - 1 : LPB_MAX_DAYS;	
        }	
        uint256 cappedStakedSuns = newStakedSuns <= BPB_MAX_SUNS	
            ? newStakedSuns	
            : BPB_MAX_SUNS;	
        bonusSuns = cappedExtraDays * BPB + cappedStakedSuns * LPB;	
        bonusSuns = newStakedSuns * bonusSuns / (LPB * BPB);	
        return bonusSuns;	
    }	
    function _stakeUnlock(GlobalsCache memory g, StakeCache memory st)	
        private	
        pure	
    {	
        g._stakeSharesTotal -= st._stakeShares;	
        st._unlockedDay = g._currentDay;	
    }	
    function _stakePerformance(GlobalsCache memory g, StakeCache memory st, uint256 servedDays)	
        private	
        view	
        returns (uint256 stakeReturn, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty)	
    {	
        if (servedDays < st._stakedDays) {	
            (payout, penalty) = _calcPayoutAndEarlyPenalty(	
                g,	
                st._lockedDay,	
                st._stakedDays,	
                servedDays,	
                st._stakeShares	
            );	
            stakeReturn = st._stakedSuns + payout;	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
        } else {	
            // servedDays must == stakedDays here	
            payout = _calcPayoutRewards(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            stakeReturn = st._stakedSuns + payout;	
            penalty = _calcLatePenalty(st._lockedDay, st._stakedDays, st._unlockedDay, stakeReturn);	
        }	
        if (penalty != 0) {	
            if (penalty > stakeReturn) {	
                /* Cannot have a negative stake return */	
                cappedPenalty = stakeReturn;	
                stakeReturn = 0;	
            } else {	
                /* Remove penalty from the stake return */	
                cappedPenalty = penalty;	
                stakeReturn -= cappedPenalty;	
            }	
        }	
        return (stakeReturn, payout, dividends, penalty, cappedPenalty);	
    }	
    function _calcPayoutAndEarlyPenalty(	
        GlobalsCache memory g,	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 servedDays,	
        uint256 stakeSharesParam	
    )	
        private	
        view	
        returns (uint256 payout, uint256 penalty)	
    {	
        uint256 servedEndDay = lockedDayParam + servedDays;	
        /* 50% of stakedDays (rounded up) with a minimum applied */	
        uint256 penaltyDays = (stakedDaysParam + 1) / 2;	
        if (penaltyDays < EARLY_PENALTY_MIN_DAYS) {	
            penaltyDays = EARLY_PENALTY_MIN_DAYS;	
        }	
        if (servedDays == 0) {	
            /* Fill penalty days with the estimated average payout */	
            uint256 expected = _estimatePayoutRewardsDay(g, stakeSharesParam, lockedDayParam);	
            penalty = expected * penaltyDays;	
            return (payout, penalty); // Actual payout was 0	
        }	
        if (penaltyDays < servedDays) {	
            /*	
                Simplified explanation of intervals where end-day is non-inclusive:	
                penalty:    [lockedDay  ...  penaltyEndDay)	
                delta:                      [penaltyEndDay  ...  servedEndDay)	
                payout:     [lockedDay  .......................  servedEndDay)	
            */	
            uint256 penaltyEndDay = lockedDayParam + penaltyDays;	
            penalty = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, penaltyEndDay);	
            uint256 delta = _calcPayoutRewards(g, stakeSharesParam, penaltyEndDay, servedEndDay);	
            payout = penalty + delta;	
            return (payout, penalty);	
        }	
        /* penaltyDays >= servedDays  */	
        payout = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, servedEndDay);	
        if (penaltyDays == servedDays) {	
            penalty = payout;	
        } else {	
            /*	
                (penaltyDays > servedDays) means not enough days served, so fill the	
                penalty days with the average payout from only the days that were served.	
            */	
            penalty = payout * penaltyDays / servedDays;	
        }	
        return (payout, penalty);	
    }	
    function _calcLatePenalty(	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 unlockedDayParam,	
        uint256 rawStakeReturn	
    )	
        private	
        pure	
        returns (uint256)	
    {	
        /* Allow grace time before penalties accrue */	
        uint256 maxUnlockedDay = lockedDayParam + stakedDaysParam + LATE_PENALTY_GRACE_DAYS;	
        if (unlockedDayParam <= maxUnlockedDay) {	
            return 0;	
        }	
        /* Calculate penalty as a percentage of stake return based on time */	
        return rawStakeReturn * (unlockedDayParam - maxUnlockedDay) / LATE_PENALTY_SCALE_DAYS;	
    }	
    function _shareRateUpdate(GlobalsCache memory g, StakeCache memory st, uint256 stakeReturn)	
        private	
    {	
        if (stakeReturn > st._stakedSuns) {	
            /*	
                Calculate the new shareRate that would yield the same number of shares if	
                the user re-staked this stakeReturn, factoring in any bonuses they would	
                receive in stakeStart().	
            */	
            uint256 bonusSuns = _stakeStartBonusSuns(stakeReturn, st._stakedDays);	
            uint256 newShareRate = (stakeReturn + bonusSuns) * SHARE_RATE_SCALE / st._stakeShares;	
            if (newShareRate > SHARE_RATE_MAX) {	
                /*	
                    Realistically this can't happen, but there are contrived theoretical	
                    scenarios that can lead to extreme values of newShareRate, so it is	
                    capped to prevent them anyway.	
                */	
                newShareRate = SHARE_RATE_MAX;	
            }	
            if (newShareRate > g._shareRate) {	
                g._shareRate = newShareRate;	
                emit ShareRateChange(	
                    st._stakeId,	
                    block.timestamp,	
                    newShareRate	
                );	
            }	
        }	
    }	
} | 
	stakeEnd | 
	function stakeEnd(uint256 stakeIndex, uint40 stakeIdParam)	
    external	
{	
    GlobalsCache memory g;	
    GlobalsCache memory gSnapshot;	
    _globalsLoad(g, gSnapshot);	
    StakeStore[] storage stakeListRef = stakeLists[msg.sender];	
    /* require() is more informative than the default assert() */	
    require(stakeListRef.length != 0, "CSNE: Empty stake list");	
    require(stakeIndex < stakeListRef.length, "CSNE: stakeIndex invalid");	
    /* Get stake copy */	
    StakeCache memory st;	
    _stakeLoad(stakeListRef[stakeIndex], stakeIdParam, st);	
    /* Check if log data needs to be updated */	
    _dailyDataUpdateAuto(g);	
    uint256 servedDays = 0;	
    bool prevUnlocked = (st._unlockedDay != 0);	
    uint256 stakeReturn;	
    uint256 payout = 0;	
    uint256 dividends = 0;	
    uint256 penalty = 0;	
    uint256 cappedPenalty = 0;	
    if (g._currentDay >= st._lockedDay) {	
        if (prevUnlocked) {	
            /* Previously unlocked in stakeGoodAccounting(), so must have served full term */	
            servedDays = st._stakedDays;	
        } else {	
            _stakeUnlock(g, st);	
            servedDays = g._currentDay - st._lockedDay;	
            if (servedDays > st._stakedDays) {	
                servedDays = st._stakedDays;	
            }	
        }	
        (stakeReturn, payout, dividends, penalty, cappedPenalty) = _stakePerformance(g, st, servedDays);	
        msg.sender.transfer(dividends);	
    } else {	
        /* Stake hasn't been added to the total yet, so no penalties or rewards apply */	
        g._nextStakeSharesTotal -= st._stakeShares;	
        stakeReturn = st._stakedSuns;	
    }	
    emit StakeEnd(	
        stakeIdParam, 	
        prevUnlocked ? 1 : 0,	
        msg.sender,	
        st._lockedDay,	
        servedDays, 	
        st._stakedSuns, 	
        st._stakeShares, 	
        dividends,	
        payout, 	
        penalty,	
        stakeReturn	
    );	
    if (cappedPenalty != 0 && !prevUnlocked) {	
        /* Split penalty proceeds only if not previously unlocked by stakeGoodAccounting() */	
        g._stakePenaltyTotal += cappedPenalty;	
    }	
    /* Pay the stake return, if any, to the staker */	
    if (stakeReturn != 0) {	
        _mint(msg.sender, stakeReturn);	
        /* Update the share rate if necessary */	
        _shareRateUpdate(g, st, stakeReturn);	
    }	
    g._lockedSunsTotal -= st._stakedSuns;	
    _stakeRemove(stakeListRef, stakeIndex);	
    _globalsSync(g, gSnapshot);	
}	
 | 
	/**	
 * @dev PUBLIC FACING: Closes a stake. The order of the stake list can change so	
 * a stake id is used to reject stale indexes.	
 * @param stakeIndex Index of stake within stake list	
 * @param stakeIdParam The stake's id	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    3295,
    6104
  ]
} | 4,611 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	StakeableToken | 
	contract StakeableToken is GlobalsAndUtility {	
    /**	
     * @dev PUBLIC FACING: Open a stake.	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function stakeStart(uint256 newStakedSuns, uint256 newStakedDays)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* Enforce the minimum stake time */	
        require(newStakedDays >= MIN_STAKE_DAYS, "CSNE: newStakedDays lower than minimum");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        _stakeStart(g, newStakedSuns, newStakedDays);	
        /* Remove staked Suns from balance of staker */	
        _burn(msg.sender, newStakedSuns);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Unlocks a completed stake, distributing the proceeds of any penalty	
     * immediately. The staker must still call stakeEnd() to retrieve their stake return (if any).	
     * @param stakerAddr Address of staker	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeGoodAccounting(address stakerAddr, uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* require() is more informative than the default assert() */	
        require(stakeLists[stakerAddr].length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeLists[stakerAddr].length, "CSNE: stakeIndex invalid");	
        StakeStore storage stRef = stakeLists[stakerAddr][stakeIndex];	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stRef, stakeIdParam, st);	
        /* Stake must have served full term */	
        require(g._currentDay >= st._lockedDay + st._stakedDays, "CSNE: Stake not fully served");	
        /* Stake must still be locked */	
        require(st._unlockedDay == 0, "CSNE: Stake already unlocked");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        /* Unlock the completed stake */	
        _stakeUnlock(g, st);	
        /* stakeReturn & dividends values are unused here */	
        (, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty) = _stakePerformance(	
            g,	
            st,	
            st._stakedDays	
        );	
        emit StakeGoodAccounting(	
            stakeIdParam,	
            stakerAddr,	
            msg.sender,	
            st._stakedSuns,	
            st._stakeShares,	
            payout,	
            penalty	
        );	
        if (cappedPenalty != 0) {	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* st._unlockedDay has changed */	
        _stakeUpdate(stRef, st);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Closes a stake. The order of the stake list can change so	
     * a stake id is used to reject stale indexes.	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeEnd(uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        StakeStore[] storage stakeListRef = stakeLists[msg.sender];	
        /* require() is more informative than the default assert() */	
        require(stakeListRef.length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeListRef.length, "CSNE: stakeIndex invalid");	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stakeListRef[stakeIndex], stakeIdParam, st);	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        uint256 servedDays = 0;	
        bool prevUnlocked = (st._unlockedDay != 0);	
        uint256 stakeReturn;	
        uint256 payout = 0;	
        uint256 dividends = 0;	
        uint256 penalty = 0;	
        uint256 cappedPenalty = 0;	
        if (g._currentDay >= st._lockedDay) {	
            if (prevUnlocked) {	
                /* Previously unlocked in stakeGoodAccounting(), so must have served full term */	
                servedDays = st._stakedDays;	
            } else {	
                _stakeUnlock(g, st);	
                servedDays = g._currentDay - st._lockedDay;	
                if (servedDays > st._stakedDays) {	
                    servedDays = st._stakedDays;	
                }	
            }	
            (stakeReturn, payout, dividends, penalty, cappedPenalty) = _stakePerformance(g, st, servedDays);	
            msg.sender.transfer(dividends);	
        } else {	
            /* Stake hasn't been added to the total yet, so no penalties or rewards apply */	
            g._nextStakeSharesTotal -= st._stakeShares;	
            stakeReturn = st._stakedSuns;	
        }	
        emit StakeEnd(	
            stakeIdParam, 	
            prevUnlocked ? 1 : 0,	
            msg.sender,	
            st._lockedDay,	
            servedDays, 	
            st._stakedSuns, 	
            st._stakeShares, 	
            dividends,	
            payout, 	
            penalty,	
            stakeReturn	
        );	
        if (cappedPenalty != 0 && !prevUnlocked) {	
            /* Split penalty proceeds only if not previously unlocked by stakeGoodAccounting() */	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* Pay the stake return, if any, to the staker */	
        if (stakeReturn != 0) {	
            _mint(msg.sender, stakeReturn);	
            /* Update the share rate if necessary */	
            _shareRateUpdate(g, st, stakeReturn);	
        }	
        g._lockedSunsTotal -= st._stakedSuns;	
        _stakeRemove(stakeListRef, stakeIndex);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the current stake count for a staker address	
     * @param stakerAddr Address of staker	
     */	
    function stakeCount(address stakerAddr)	
        external	
        view	
        returns (uint256)	
    {	
        return stakeLists[stakerAddr].length;	
    }	
    /**	
     * @dev Open a stake.	
     * @param g Cache of stored globals	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStart(	
        GlobalsCache memory g,	
        uint256 newStakedSuns,	
        uint256 newStakedDays	
    )	
        internal	
    {	
        /* Enforce the maximum stake time */	
        require(newStakedDays <= MAX_STAKE_DAYS, "CSNE: newStakedDays higher than maximum");	
        uint256 bonusSuns = _stakeStartBonusSuns(newStakedSuns, newStakedDays);	
        uint256 newStakeShares = (newStakedSuns + bonusSuns) * SHARE_RATE_SCALE / g._shareRate;	
        /* Ensure newStakedSuns is enough for at least one stake share */	
        require(newStakeShares != 0, "CSNE: newStakedSuns must be at least minimum shareRate");	
        /*	
            The stakeStart timestamp will always be part-way through the current	
            day, so it needs to be rounded-up to the next day to ensure all	
            stakes align with the same fixed calendar days. The current day is	
            already rounded-down, so rounded-up is current day + 1.	
        */	
        uint256 newLockedDay = g._currentDay + 1;	
        /* Create Stake */	
        uint40 newStakeId = ++g._latestStakeId;	
        _stakeAdd(	
            stakeLists[msg.sender],	
            newStakeId,	
            newStakedSuns,	
            newStakeShares,	
            newLockedDay,	
            newStakedDays	
        );	
        emit StakeStart(	
            newStakeId, 	
            msg.sender,	
            newStakedSuns, 	
            newStakeShares, 	
            newStakedDays	
        );	
        /* Stake is added to total in the next round, not the current round */	
        g._nextStakeSharesTotal += newStakeShares;	
        /* Track total staked Suns for inflation calculations */	
        g._lockedSunsTotal += newStakedSuns;	
    }	
    /**	
     * @dev Calculates total stake payout including rewards for a multi-day range	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutRewards(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        uint256 counter;	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            dayPayout = dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal;	
            if (counter < 4) {	
                counter++;	
            } 	
            /* Eligible to receive bonus */	
            else {	
                dayPayout = (dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal) * BONUS_DAY_SCALE;	
                counter = 0;	
            }	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculates user dividends	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutDividendsReward(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            /* user's share of 95% of the day's dividends */	
            dayPayout += ((dailyData[day].dayDividends * 95) / 100) * stakeSharesParam	
            / dailyData[day].dayStakeSharesTotal;	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculate bonus Suns for a new stake, if any	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStartBonusSuns(uint256 newStakedSuns, uint256 newStakedDays)	
        private	
        pure	
        returns (uint256 bonusSuns)	
    {	
       
        uint256 cappedExtraDays = 0;	
        /* Must be more than 1 day for Longer-Pays-Better */	
        if (newStakedDays > 1) {	
            cappedExtraDays = newStakedDays <= LPB_MAX_DAYS ? newStakedDays - 1 : LPB_MAX_DAYS;	
        }	
        uint256 cappedStakedSuns = newStakedSuns <= BPB_MAX_SUNS	
            ? newStakedSuns	
            : BPB_MAX_SUNS;	
        bonusSuns = cappedExtraDays * BPB + cappedStakedSuns * LPB;	
        bonusSuns = newStakedSuns * bonusSuns / (LPB * BPB);	
        return bonusSuns;	
    }	
    function _stakeUnlock(GlobalsCache memory g, StakeCache memory st)	
        private	
        pure	
    {	
        g._stakeSharesTotal -= st._stakeShares;	
        st._unlockedDay = g._currentDay;	
    }	
    function _stakePerformance(GlobalsCache memory g, StakeCache memory st, uint256 servedDays)	
        private	
        view	
        returns (uint256 stakeReturn, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty)	
    {	
        if (servedDays < st._stakedDays) {	
            (payout, penalty) = _calcPayoutAndEarlyPenalty(	
                g,	
                st._lockedDay,	
                st._stakedDays,	
                servedDays,	
                st._stakeShares	
            );	
            stakeReturn = st._stakedSuns + payout;	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
        } else {	
            // servedDays must == stakedDays here	
            payout = _calcPayoutRewards(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            stakeReturn = st._stakedSuns + payout;	
            penalty = _calcLatePenalty(st._lockedDay, st._stakedDays, st._unlockedDay, stakeReturn);	
        }	
        if (penalty != 0) {	
            if (penalty > stakeReturn) {	
                /* Cannot have a negative stake return */	
                cappedPenalty = stakeReturn;	
                stakeReturn = 0;	
            } else {	
                /* Remove penalty from the stake return */	
                cappedPenalty = penalty;	
                stakeReturn -= cappedPenalty;	
            }	
        }	
        return (stakeReturn, payout, dividends, penalty, cappedPenalty);	
    }	
    function _calcPayoutAndEarlyPenalty(	
        GlobalsCache memory g,	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 servedDays,	
        uint256 stakeSharesParam	
    )	
        private	
        view	
        returns (uint256 payout, uint256 penalty)	
    {	
        uint256 servedEndDay = lockedDayParam + servedDays;	
        /* 50% of stakedDays (rounded up) with a minimum applied */	
        uint256 penaltyDays = (stakedDaysParam + 1) / 2;	
        if (penaltyDays < EARLY_PENALTY_MIN_DAYS) {	
            penaltyDays = EARLY_PENALTY_MIN_DAYS;	
        }	
        if (servedDays == 0) {	
            /* Fill penalty days with the estimated average payout */	
            uint256 expected = _estimatePayoutRewardsDay(g, stakeSharesParam, lockedDayParam);	
            penalty = expected * penaltyDays;	
            return (payout, penalty); // Actual payout was 0	
        }	
        if (penaltyDays < servedDays) {	
            /*	
                Simplified explanation of intervals where end-day is non-inclusive:	
                penalty:    [lockedDay  ...  penaltyEndDay)	
                delta:                      [penaltyEndDay  ...  servedEndDay)	
                payout:     [lockedDay  .......................  servedEndDay)	
            */	
            uint256 penaltyEndDay = lockedDayParam + penaltyDays;	
            penalty = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, penaltyEndDay);	
            uint256 delta = _calcPayoutRewards(g, stakeSharesParam, penaltyEndDay, servedEndDay);	
            payout = penalty + delta;	
            return (payout, penalty);	
        }	
        /* penaltyDays >= servedDays  */	
        payout = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, servedEndDay);	
        if (penaltyDays == servedDays) {	
            penalty = payout;	
        } else {	
            /*	
                (penaltyDays > servedDays) means not enough days served, so fill the	
                penalty days with the average payout from only the days that were served.	
            */	
            penalty = payout * penaltyDays / servedDays;	
        }	
        return (payout, penalty);	
    }	
    function _calcLatePenalty(	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 unlockedDayParam,	
        uint256 rawStakeReturn	
    )	
        private	
        pure	
        returns (uint256)	
    {	
        /* Allow grace time before penalties accrue */	
        uint256 maxUnlockedDay = lockedDayParam + stakedDaysParam + LATE_PENALTY_GRACE_DAYS;	
        if (unlockedDayParam <= maxUnlockedDay) {	
            return 0;	
        }	
        /* Calculate penalty as a percentage of stake return based on time */	
        return rawStakeReturn * (unlockedDayParam - maxUnlockedDay) / LATE_PENALTY_SCALE_DAYS;	
    }	
    function _shareRateUpdate(GlobalsCache memory g, StakeCache memory st, uint256 stakeReturn)	
        private	
    {	
        if (stakeReturn > st._stakedSuns) {	
            /*	
                Calculate the new shareRate that would yield the same number of shares if	
                the user re-staked this stakeReturn, factoring in any bonuses they would	
                receive in stakeStart().	
            */	
            uint256 bonusSuns = _stakeStartBonusSuns(stakeReturn, st._stakedDays);	
            uint256 newShareRate = (stakeReturn + bonusSuns) * SHARE_RATE_SCALE / st._stakeShares;	
            if (newShareRate > SHARE_RATE_MAX) {	
                /*	
                    Realistically this can't happen, but there are contrived theoretical	
                    scenarios that can lead to extreme values of newShareRate, so it is	
                    capped to prevent them anyway.	
                */	
                newShareRate = SHARE_RATE_MAX;	
            }	
            if (newShareRate > g._shareRate) {	
                g._shareRate = newShareRate;	
                emit ShareRateChange(	
                    st._stakeId,	
                    block.timestamp,	
                    newShareRate	
                );	
            }	
        }	
    }	
} | 
	stakeCount | 
	function stakeCount(address stakerAddr)	
    external	
    view	
    returns (uint256)	
{	
    return stakeLists[stakerAddr].length;	
}	
 | 
	/**	
 * @dev PUBLIC FACING: Return the current stake count for a staker address	
 * @param stakerAddr Address of staker	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    6251,
    6422
  ]
} | 4,612 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	StakeableToken | 
	contract StakeableToken is GlobalsAndUtility {	
    /**	
     * @dev PUBLIC FACING: Open a stake.	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function stakeStart(uint256 newStakedSuns, uint256 newStakedDays)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* Enforce the minimum stake time */	
        require(newStakedDays >= MIN_STAKE_DAYS, "CSNE: newStakedDays lower than minimum");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        _stakeStart(g, newStakedSuns, newStakedDays);	
        /* Remove staked Suns from balance of staker */	
        _burn(msg.sender, newStakedSuns);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Unlocks a completed stake, distributing the proceeds of any penalty	
     * immediately. The staker must still call stakeEnd() to retrieve their stake return (if any).	
     * @param stakerAddr Address of staker	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeGoodAccounting(address stakerAddr, uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* require() is more informative than the default assert() */	
        require(stakeLists[stakerAddr].length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeLists[stakerAddr].length, "CSNE: stakeIndex invalid");	
        StakeStore storage stRef = stakeLists[stakerAddr][stakeIndex];	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stRef, stakeIdParam, st);	
        /* Stake must have served full term */	
        require(g._currentDay >= st._lockedDay + st._stakedDays, "CSNE: Stake not fully served");	
        /* Stake must still be locked */	
        require(st._unlockedDay == 0, "CSNE: Stake already unlocked");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        /* Unlock the completed stake */	
        _stakeUnlock(g, st);	
        /* stakeReturn & dividends values are unused here */	
        (, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty) = _stakePerformance(	
            g,	
            st,	
            st._stakedDays	
        );	
        emit StakeGoodAccounting(	
            stakeIdParam,	
            stakerAddr,	
            msg.sender,	
            st._stakedSuns,	
            st._stakeShares,	
            payout,	
            penalty	
        );	
        if (cappedPenalty != 0) {	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* st._unlockedDay has changed */	
        _stakeUpdate(stRef, st);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Closes a stake. The order of the stake list can change so	
     * a stake id is used to reject stale indexes.	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeEnd(uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        StakeStore[] storage stakeListRef = stakeLists[msg.sender];	
        /* require() is more informative than the default assert() */	
        require(stakeListRef.length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeListRef.length, "CSNE: stakeIndex invalid");	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stakeListRef[stakeIndex], stakeIdParam, st);	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        uint256 servedDays = 0;	
        bool prevUnlocked = (st._unlockedDay != 0);	
        uint256 stakeReturn;	
        uint256 payout = 0;	
        uint256 dividends = 0;	
        uint256 penalty = 0;	
        uint256 cappedPenalty = 0;	
        if (g._currentDay >= st._lockedDay) {	
            if (prevUnlocked) {	
                /* Previously unlocked in stakeGoodAccounting(), so must have served full term */	
                servedDays = st._stakedDays;	
            } else {	
                _stakeUnlock(g, st);	
                servedDays = g._currentDay - st._lockedDay;	
                if (servedDays > st._stakedDays) {	
                    servedDays = st._stakedDays;	
                }	
            }	
            (stakeReturn, payout, dividends, penalty, cappedPenalty) = _stakePerformance(g, st, servedDays);	
            msg.sender.transfer(dividends);	
        } else {	
            /* Stake hasn't been added to the total yet, so no penalties or rewards apply */	
            g._nextStakeSharesTotal -= st._stakeShares;	
            stakeReturn = st._stakedSuns;	
        }	
        emit StakeEnd(	
            stakeIdParam, 	
            prevUnlocked ? 1 : 0,	
            msg.sender,	
            st._lockedDay,	
            servedDays, 	
            st._stakedSuns, 	
            st._stakeShares, 	
            dividends,	
            payout, 	
            penalty,	
            stakeReturn	
        );	
        if (cappedPenalty != 0 && !prevUnlocked) {	
            /* Split penalty proceeds only if not previously unlocked by stakeGoodAccounting() */	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* Pay the stake return, if any, to the staker */	
        if (stakeReturn != 0) {	
            _mint(msg.sender, stakeReturn);	
            /* Update the share rate if necessary */	
            _shareRateUpdate(g, st, stakeReturn);	
        }	
        g._lockedSunsTotal -= st._stakedSuns;	
        _stakeRemove(stakeListRef, stakeIndex);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the current stake count for a staker address	
     * @param stakerAddr Address of staker	
     */	
    function stakeCount(address stakerAddr)	
        external	
        view	
        returns (uint256)	
    {	
        return stakeLists[stakerAddr].length;	
    }	
    /**	
     * @dev Open a stake.	
     * @param g Cache of stored globals	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStart(	
        GlobalsCache memory g,	
        uint256 newStakedSuns,	
        uint256 newStakedDays	
    )	
        internal	
    {	
        /* Enforce the maximum stake time */	
        require(newStakedDays <= MAX_STAKE_DAYS, "CSNE: newStakedDays higher than maximum");	
        uint256 bonusSuns = _stakeStartBonusSuns(newStakedSuns, newStakedDays);	
        uint256 newStakeShares = (newStakedSuns + bonusSuns) * SHARE_RATE_SCALE / g._shareRate;	
        /* Ensure newStakedSuns is enough for at least one stake share */	
        require(newStakeShares != 0, "CSNE: newStakedSuns must be at least minimum shareRate");	
        /*	
            The stakeStart timestamp will always be part-way through the current	
            day, so it needs to be rounded-up to the next day to ensure all	
            stakes align with the same fixed calendar days. The current day is	
            already rounded-down, so rounded-up is current day + 1.	
        */	
        uint256 newLockedDay = g._currentDay + 1;	
        /* Create Stake */	
        uint40 newStakeId = ++g._latestStakeId;	
        _stakeAdd(	
            stakeLists[msg.sender],	
            newStakeId,	
            newStakedSuns,	
            newStakeShares,	
            newLockedDay,	
            newStakedDays	
        );	
        emit StakeStart(	
            newStakeId, 	
            msg.sender,	
            newStakedSuns, 	
            newStakeShares, 	
            newStakedDays	
        );	
        /* Stake is added to total in the next round, not the current round */	
        g._nextStakeSharesTotal += newStakeShares;	
        /* Track total staked Suns for inflation calculations */	
        g._lockedSunsTotal += newStakedSuns;	
    }	
    /**	
     * @dev Calculates total stake payout including rewards for a multi-day range	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutRewards(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        uint256 counter;	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            dayPayout = dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal;	
            if (counter < 4) {	
                counter++;	
            } 	
            /* Eligible to receive bonus */	
            else {	
                dayPayout = (dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal) * BONUS_DAY_SCALE;	
                counter = 0;	
            }	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculates user dividends	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutDividendsReward(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            /* user's share of 95% of the day's dividends */	
            dayPayout += ((dailyData[day].dayDividends * 95) / 100) * stakeSharesParam	
            / dailyData[day].dayStakeSharesTotal;	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculate bonus Suns for a new stake, if any	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStartBonusSuns(uint256 newStakedSuns, uint256 newStakedDays)	
        private	
        pure	
        returns (uint256 bonusSuns)	
    {	
       
        uint256 cappedExtraDays = 0;	
        /* Must be more than 1 day for Longer-Pays-Better */	
        if (newStakedDays > 1) {	
            cappedExtraDays = newStakedDays <= LPB_MAX_DAYS ? newStakedDays - 1 : LPB_MAX_DAYS;	
        }	
        uint256 cappedStakedSuns = newStakedSuns <= BPB_MAX_SUNS	
            ? newStakedSuns	
            : BPB_MAX_SUNS;	
        bonusSuns = cappedExtraDays * BPB + cappedStakedSuns * LPB;	
        bonusSuns = newStakedSuns * bonusSuns / (LPB * BPB);	
        return bonusSuns;	
    }	
    function _stakeUnlock(GlobalsCache memory g, StakeCache memory st)	
        private	
        pure	
    {	
        g._stakeSharesTotal -= st._stakeShares;	
        st._unlockedDay = g._currentDay;	
    }	
    function _stakePerformance(GlobalsCache memory g, StakeCache memory st, uint256 servedDays)	
        private	
        view	
        returns (uint256 stakeReturn, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty)	
    {	
        if (servedDays < st._stakedDays) {	
            (payout, penalty) = _calcPayoutAndEarlyPenalty(	
                g,	
                st._lockedDay,	
                st._stakedDays,	
                servedDays,	
                st._stakeShares	
            );	
            stakeReturn = st._stakedSuns + payout;	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
        } else {	
            // servedDays must == stakedDays here	
            payout = _calcPayoutRewards(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            stakeReturn = st._stakedSuns + payout;	
            penalty = _calcLatePenalty(st._lockedDay, st._stakedDays, st._unlockedDay, stakeReturn);	
        }	
        if (penalty != 0) {	
            if (penalty > stakeReturn) {	
                /* Cannot have a negative stake return */	
                cappedPenalty = stakeReturn;	
                stakeReturn = 0;	
            } else {	
                /* Remove penalty from the stake return */	
                cappedPenalty = penalty;	
                stakeReturn -= cappedPenalty;	
            }	
        }	
        return (stakeReturn, payout, dividends, penalty, cappedPenalty);	
    }	
    function _calcPayoutAndEarlyPenalty(	
        GlobalsCache memory g,	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 servedDays,	
        uint256 stakeSharesParam	
    )	
        private	
        view	
        returns (uint256 payout, uint256 penalty)	
    {	
        uint256 servedEndDay = lockedDayParam + servedDays;	
        /* 50% of stakedDays (rounded up) with a minimum applied */	
        uint256 penaltyDays = (stakedDaysParam + 1) / 2;	
        if (penaltyDays < EARLY_PENALTY_MIN_DAYS) {	
            penaltyDays = EARLY_PENALTY_MIN_DAYS;	
        }	
        if (servedDays == 0) {	
            /* Fill penalty days with the estimated average payout */	
            uint256 expected = _estimatePayoutRewardsDay(g, stakeSharesParam, lockedDayParam);	
            penalty = expected * penaltyDays;	
            return (payout, penalty); // Actual payout was 0	
        }	
        if (penaltyDays < servedDays) {	
            /*	
                Simplified explanation of intervals where end-day is non-inclusive:	
                penalty:    [lockedDay  ...  penaltyEndDay)	
                delta:                      [penaltyEndDay  ...  servedEndDay)	
                payout:     [lockedDay  .......................  servedEndDay)	
            */	
            uint256 penaltyEndDay = lockedDayParam + penaltyDays;	
            penalty = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, penaltyEndDay);	
            uint256 delta = _calcPayoutRewards(g, stakeSharesParam, penaltyEndDay, servedEndDay);	
            payout = penalty + delta;	
            return (payout, penalty);	
        }	
        /* penaltyDays >= servedDays  */	
        payout = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, servedEndDay);	
        if (penaltyDays == servedDays) {	
            penalty = payout;	
        } else {	
            /*	
                (penaltyDays > servedDays) means not enough days served, so fill the	
                penalty days with the average payout from only the days that were served.	
            */	
            penalty = payout * penaltyDays / servedDays;	
        }	
        return (payout, penalty);	
    }	
    function _calcLatePenalty(	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 unlockedDayParam,	
        uint256 rawStakeReturn	
    )	
        private	
        pure	
        returns (uint256)	
    {	
        /* Allow grace time before penalties accrue */	
        uint256 maxUnlockedDay = lockedDayParam + stakedDaysParam + LATE_PENALTY_GRACE_DAYS;	
        if (unlockedDayParam <= maxUnlockedDay) {	
            return 0;	
        }	
        /* Calculate penalty as a percentage of stake return based on time */	
        return rawStakeReturn * (unlockedDayParam - maxUnlockedDay) / LATE_PENALTY_SCALE_DAYS;	
    }	
    function _shareRateUpdate(GlobalsCache memory g, StakeCache memory st, uint256 stakeReturn)	
        private	
    {	
        if (stakeReturn > st._stakedSuns) {	
            /*	
                Calculate the new shareRate that would yield the same number of shares if	
                the user re-staked this stakeReturn, factoring in any bonuses they would	
                receive in stakeStart().	
            */	
            uint256 bonusSuns = _stakeStartBonusSuns(stakeReturn, st._stakedDays);	
            uint256 newShareRate = (stakeReturn + bonusSuns) * SHARE_RATE_SCALE / st._stakeShares;	
            if (newShareRate > SHARE_RATE_MAX) {	
                /*	
                    Realistically this can't happen, but there are contrived theoretical	
                    scenarios that can lead to extreme values of newShareRate, so it is	
                    capped to prevent them anyway.	
                */	
                newShareRate = SHARE_RATE_MAX;	
            }	
            if (newShareRate > g._shareRate) {	
                g._shareRate = newShareRate;	
                emit ShareRateChange(	
                    st._stakeId,	
                    block.timestamp,	
                    newShareRate	
                );	
            }	
        }	
    }	
} | 
	_stakeStart | 
	function _stakeStart(	
    GlobalsCache memory g,	
    uint256 newStakedSuns,	
    uint256 newStakedDays	
)	
    internal	
{	
    /* Enforce the maximum stake time */	
    require(newStakedDays <= MAX_STAKE_DAYS, "CSNE: newStakedDays higher than maximum");	
    uint256 bonusSuns = _stakeStartBonusSuns(newStakedSuns, newStakedDays);	
    uint256 newStakeShares = (newStakedSuns + bonusSuns) * SHARE_RATE_SCALE / g._shareRate;	
    /* Ensure newStakedSuns is enough for at least one stake share */	
    require(newStakeShares != 0, "CSNE: newStakedSuns must be at least minimum shareRate");	
    /*	
        The stakeStart timestamp will always be part-way through the current	
        day, so it needs to be rounded-up to the next day to ensure all	
        stakes align with the same fixed calendar days. The current day is	
        already rounded-down, so rounded-up is current day + 1.	
    */	
    uint256 newLockedDay = g._currentDay + 1;	
    /* Create Stake */	
    uint40 newStakeId = ++g._latestStakeId;	
    _stakeAdd(	
        stakeLists[msg.sender],	
        newStakeId,	
        newStakedSuns,	
        newStakeShares,	
        newLockedDay,	
        newStakedDays	
    );	
    emit StakeStart(	
        newStakeId, 	
        msg.sender,	
        newStakedSuns, 	
        newStakeShares, 	
        newStakedDays	
    );	
    /* Stake is added to total in the next round, not the current round */	
    g._nextStakeSharesTotal += newStakeShares;	
    /* Track total staked Suns for inflation calculations */	
    g._lockedSunsTotal += newStakedSuns;	
}	
 | 
	/**	
 * @dev Open a stake.	
 * @param g Cache of stored globals	
 * @param newStakedSuns Number of Suns to stake	
 * @param newStakedDays Number of days to stake	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    6621,
    8397
  ]
} | 4,613 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	StakeableToken | 
	contract StakeableToken is GlobalsAndUtility {	
    /**	
     * @dev PUBLIC FACING: Open a stake.	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function stakeStart(uint256 newStakedSuns, uint256 newStakedDays)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* Enforce the minimum stake time */	
        require(newStakedDays >= MIN_STAKE_DAYS, "CSNE: newStakedDays lower than minimum");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        _stakeStart(g, newStakedSuns, newStakedDays);	
        /* Remove staked Suns from balance of staker */	
        _burn(msg.sender, newStakedSuns);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Unlocks a completed stake, distributing the proceeds of any penalty	
     * immediately. The staker must still call stakeEnd() to retrieve their stake return (if any).	
     * @param stakerAddr Address of staker	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeGoodAccounting(address stakerAddr, uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* require() is more informative than the default assert() */	
        require(stakeLists[stakerAddr].length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeLists[stakerAddr].length, "CSNE: stakeIndex invalid");	
        StakeStore storage stRef = stakeLists[stakerAddr][stakeIndex];	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stRef, stakeIdParam, st);	
        /* Stake must have served full term */	
        require(g._currentDay >= st._lockedDay + st._stakedDays, "CSNE: Stake not fully served");	
        /* Stake must still be locked */	
        require(st._unlockedDay == 0, "CSNE: Stake already unlocked");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        /* Unlock the completed stake */	
        _stakeUnlock(g, st);	
        /* stakeReturn & dividends values are unused here */	
        (, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty) = _stakePerformance(	
            g,	
            st,	
            st._stakedDays	
        );	
        emit StakeGoodAccounting(	
            stakeIdParam,	
            stakerAddr,	
            msg.sender,	
            st._stakedSuns,	
            st._stakeShares,	
            payout,	
            penalty	
        );	
        if (cappedPenalty != 0) {	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* st._unlockedDay has changed */	
        _stakeUpdate(stRef, st);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Closes a stake. The order of the stake list can change so	
     * a stake id is used to reject stale indexes.	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeEnd(uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        StakeStore[] storage stakeListRef = stakeLists[msg.sender];	
        /* require() is more informative than the default assert() */	
        require(stakeListRef.length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeListRef.length, "CSNE: stakeIndex invalid");	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stakeListRef[stakeIndex], stakeIdParam, st);	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        uint256 servedDays = 0;	
        bool prevUnlocked = (st._unlockedDay != 0);	
        uint256 stakeReturn;	
        uint256 payout = 0;	
        uint256 dividends = 0;	
        uint256 penalty = 0;	
        uint256 cappedPenalty = 0;	
        if (g._currentDay >= st._lockedDay) {	
            if (prevUnlocked) {	
                /* Previously unlocked in stakeGoodAccounting(), so must have served full term */	
                servedDays = st._stakedDays;	
            } else {	
                _stakeUnlock(g, st);	
                servedDays = g._currentDay - st._lockedDay;	
                if (servedDays > st._stakedDays) {	
                    servedDays = st._stakedDays;	
                }	
            }	
            (stakeReturn, payout, dividends, penalty, cappedPenalty) = _stakePerformance(g, st, servedDays);	
            msg.sender.transfer(dividends);	
        } else {	
            /* Stake hasn't been added to the total yet, so no penalties or rewards apply */	
            g._nextStakeSharesTotal -= st._stakeShares;	
            stakeReturn = st._stakedSuns;	
        }	
        emit StakeEnd(	
            stakeIdParam, 	
            prevUnlocked ? 1 : 0,	
            msg.sender,	
            st._lockedDay,	
            servedDays, 	
            st._stakedSuns, 	
            st._stakeShares, 	
            dividends,	
            payout, 	
            penalty,	
            stakeReturn	
        );	
        if (cappedPenalty != 0 && !prevUnlocked) {	
            /* Split penalty proceeds only if not previously unlocked by stakeGoodAccounting() */	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* Pay the stake return, if any, to the staker */	
        if (stakeReturn != 0) {	
            _mint(msg.sender, stakeReturn);	
            /* Update the share rate if necessary */	
            _shareRateUpdate(g, st, stakeReturn);	
        }	
        g._lockedSunsTotal -= st._stakedSuns;	
        _stakeRemove(stakeListRef, stakeIndex);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the current stake count for a staker address	
     * @param stakerAddr Address of staker	
     */	
    function stakeCount(address stakerAddr)	
        external	
        view	
        returns (uint256)	
    {	
        return stakeLists[stakerAddr].length;	
    }	
    /**	
     * @dev Open a stake.	
     * @param g Cache of stored globals	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStart(	
        GlobalsCache memory g,	
        uint256 newStakedSuns,	
        uint256 newStakedDays	
    )	
        internal	
    {	
        /* Enforce the maximum stake time */	
        require(newStakedDays <= MAX_STAKE_DAYS, "CSNE: newStakedDays higher than maximum");	
        uint256 bonusSuns = _stakeStartBonusSuns(newStakedSuns, newStakedDays);	
        uint256 newStakeShares = (newStakedSuns + bonusSuns) * SHARE_RATE_SCALE / g._shareRate;	
        /* Ensure newStakedSuns is enough for at least one stake share */	
        require(newStakeShares != 0, "CSNE: newStakedSuns must be at least minimum shareRate");	
        /*	
            The stakeStart timestamp will always be part-way through the current	
            day, so it needs to be rounded-up to the next day to ensure all	
            stakes align with the same fixed calendar days. The current day is	
            already rounded-down, so rounded-up is current day + 1.	
        */	
        uint256 newLockedDay = g._currentDay + 1;	
        /* Create Stake */	
        uint40 newStakeId = ++g._latestStakeId;	
        _stakeAdd(	
            stakeLists[msg.sender],	
            newStakeId,	
            newStakedSuns,	
            newStakeShares,	
            newLockedDay,	
            newStakedDays	
        );	
        emit StakeStart(	
            newStakeId, 	
            msg.sender,	
            newStakedSuns, 	
            newStakeShares, 	
            newStakedDays	
        );	
        /* Stake is added to total in the next round, not the current round */	
        g._nextStakeSharesTotal += newStakeShares;	
        /* Track total staked Suns for inflation calculations */	
        g._lockedSunsTotal += newStakedSuns;	
    }	
    /**	
     * @dev Calculates total stake payout including rewards for a multi-day range	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutRewards(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        uint256 counter;	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            dayPayout = dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal;	
            if (counter < 4) {	
                counter++;	
            } 	
            /* Eligible to receive bonus */	
            else {	
                dayPayout = (dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal) * BONUS_DAY_SCALE;	
                counter = 0;	
            }	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculates user dividends	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutDividendsReward(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            /* user's share of 95% of the day's dividends */	
            dayPayout += ((dailyData[day].dayDividends * 95) / 100) * stakeSharesParam	
            / dailyData[day].dayStakeSharesTotal;	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculate bonus Suns for a new stake, if any	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStartBonusSuns(uint256 newStakedSuns, uint256 newStakedDays)	
        private	
        pure	
        returns (uint256 bonusSuns)	
    {	
       
        uint256 cappedExtraDays = 0;	
        /* Must be more than 1 day for Longer-Pays-Better */	
        if (newStakedDays > 1) {	
            cappedExtraDays = newStakedDays <= LPB_MAX_DAYS ? newStakedDays - 1 : LPB_MAX_DAYS;	
        }	
        uint256 cappedStakedSuns = newStakedSuns <= BPB_MAX_SUNS	
            ? newStakedSuns	
            : BPB_MAX_SUNS;	
        bonusSuns = cappedExtraDays * BPB + cappedStakedSuns * LPB;	
        bonusSuns = newStakedSuns * bonusSuns / (LPB * BPB);	
        return bonusSuns;	
    }	
    function _stakeUnlock(GlobalsCache memory g, StakeCache memory st)	
        private	
        pure	
    {	
        g._stakeSharesTotal -= st._stakeShares;	
        st._unlockedDay = g._currentDay;	
    }	
    function _stakePerformance(GlobalsCache memory g, StakeCache memory st, uint256 servedDays)	
        private	
        view	
        returns (uint256 stakeReturn, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty)	
    {	
        if (servedDays < st._stakedDays) {	
            (payout, penalty) = _calcPayoutAndEarlyPenalty(	
                g,	
                st._lockedDay,	
                st._stakedDays,	
                servedDays,	
                st._stakeShares	
            );	
            stakeReturn = st._stakedSuns + payout;	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
        } else {	
            // servedDays must == stakedDays here	
            payout = _calcPayoutRewards(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            stakeReturn = st._stakedSuns + payout;	
            penalty = _calcLatePenalty(st._lockedDay, st._stakedDays, st._unlockedDay, stakeReturn);	
        }	
        if (penalty != 0) {	
            if (penalty > stakeReturn) {	
                /* Cannot have a negative stake return */	
                cappedPenalty = stakeReturn;	
                stakeReturn = 0;	
            } else {	
                /* Remove penalty from the stake return */	
                cappedPenalty = penalty;	
                stakeReturn -= cappedPenalty;	
            }	
        }	
        return (stakeReturn, payout, dividends, penalty, cappedPenalty);	
    }	
    function _calcPayoutAndEarlyPenalty(	
        GlobalsCache memory g,	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 servedDays,	
        uint256 stakeSharesParam	
    )	
        private	
        view	
        returns (uint256 payout, uint256 penalty)	
    {	
        uint256 servedEndDay = lockedDayParam + servedDays;	
        /* 50% of stakedDays (rounded up) with a minimum applied */	
        uint256 penaltyDays = (stakedDaysParam + 1) / 2;	
        if (penaltyDays < EARLY_PENALTY_MIN_DAYS) {	
            penaltyDays = EARLY_PENALTY_MIN_DAYS;	
        }	
        if (servedDays == 0) {	
            /* Fill penalty days with the estimated average payout */	
            uint256 expected = _estimatePayoutRewardsDay(g, stakeSharesParam, lockedDayParam);	
            penalty = expected * penaltyDays;	
            return (payout, penalty); // Actual payout was 0	
        }	
        if (penaltyDays < servedDays) {	
            /*	
                Simplified explanation of intervals where end-day is non-inclusive:	
                penalty:    [lockedDay  ...  penaltyEndDay)	
                delta:                      [penaltyEndDay  ...  servedEndDay)	
                payout:     [lockedDay  .......................  servedEndDay)	
            */	
            uint256 penaltyEndDay = lockedDayParam + penaltyDays;	
            penalty = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, penaltyEndDay);	
            uint256 delta = _calcPayoutRewards(g, stakeSharesParam, penaltyEndDay, servedEndDay);	
            payout = penalty + delta;	
            return (payout, penalty);	
        }	
        /* penaltyDays >= servedDays  */	
        payout = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, servedEndDay);	
        if (penaltyDays == servedDays) {	
            penalty = payout;	
        } else {	
            /*	
                (penaltyDays > servedDays) means not enough days served, so fill the	
                penalty days with the average payout from only the days that were served.	
            */	
            penalty = payout * penaltyDays / servedDays;	
        }	
        return (payout, penalty);	
    }	
    function _calcLatePenalty(	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 unlockedDayParam,	
        uint256 rawStakeReturn	
    )	
        private	
        pure	
        returns (uint256)	
    {	
        /* Allow grace time before penalties accrue */	
        uint256 maxUnlockedDay = lockedDayParam + stakedDaysParam + LATE_PENALTY_GRACE_DAYS;	
        if (unlockedDayParam <= maxUnlockedDay) {	
            return 0;	
        }	
        /* Calculate penalty as a percentage of stake return based on time */	
        return rawStakeReturn * (unlockedDayParam - maxUnlockedDay) / LATE_PENALTY_SCALE_DAYS;	
    }	
    function _shareRateUpdate(GlobalsCache memory g, StakeCache memory st, uint256 stakeReturn)	
        private	
    {	
        if (stakeReturn > st._stakedSuns) {	
            /*	
                Calculate the new shareRate that would yield the same number of shares if	
                the user re-staked this stakeReturn, factoring in any bonuses they would	
                receive in stakeStart().	
            */	
            uint256 bonusSuns = _stakeStartBonusSuns(stakeReturn, st._stakedDays);	
            uint256 newShareRate = (stakeReturn + bonusSuns) * SHARE_RATE_SCALE / st._stakeShares;	
            if (newShareRate > SHARE_RATE_MAX) {	
                /*	
                    Realistically this can't happen, but there are contrived theoretical	
                    scenarios that can lead to extreme values of newShareRate, so it is	
                    capped to prevent them anyway.	
                */	
                newShareRate = SHARE_RATE_MAX;	
            }	
            if (newShareRate > g._shareRate) {	
                g._shareRate = newShareRate;	
                emit ShareRateChange(	
                    st._stakeId,	
                    block.timestamp,	
                    newShareRate	
                );	
            }	
        }	
    }	
} | 
	_calcPayoutRewards | 
	function _calcPayoutRewards(	
    GlobalsCache memory g,	
    uint256 stakeSharesParam,	
    uint256 beginDay,	
    uint256 endDay	
)	
    private	
    view	
    returns (uint256 payout)	
{	
    uint256 counter;	
    for (uint256 day = beginDay; day < endDay; day++) {	
        uint256 dayPayout;	
        dayPayout = dailyData[day].dayPayoutTotal * stakeSharesParam	
            / dailyData[day].dayStakeSharesTotal;	
        if (counter < 4) {	
            counter++;	
        } 	
        /* Eligible to receive bonus */	
        else {	
            dayPayout = (dailyData[day].dayPayoutTotal * stakeSharesParam	
            / dailyData[day].dayStakeSharesTotal) * BONUS_DAY_SCALE;	
            counter = 0;	
        }	
        payout += dayPayout;	
    }	
    return payout;	
}	
 | 
	/**	
 * @dev Calculates total stake payout including rewards for a multi-day range	
 * @param g Cache of stored globals	
 * @param stakeSharesParam Param from stake to calculate bonuses for	
 * @param beginDay First day to calculate bonuses for	
 * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
 * @return Payout in Suns	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    8793,
    9714
  ]
} | 4,614 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	StakeableToken | 
	contract StakeableToken is GlobalsAndUtility {	
    /**	
     * @dev PUBLIC FACING: Open a stake.	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function stakeStart(uint256 newStakedSuns, uint256 newStakedDays)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* Enforce the minimum stake time */	
        require(newStakedDays >= MIN_STAKE_DAYS, "CSNE: newStakedDays lower than minimum");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        _stakeStart(g, newStakedSuns, newStakedDays);	
        /* Remove staked Suns from balance of staker */	
        _burn(msg.sender, newStakedSuns);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Unlocks a completed stake, distributing the proceeds of any penalty	
     * immediately. The staker must still call stakeEnd() to retrieve their stake return (if any).	
     * @param stakerAddr Address of staker	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeGoodAccounting(address stakerAddr, uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* require() is more informative than the default assert() */	
        require(stakeLists[stakerAddr].length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeLists[stakerAddr].length, "CSNE: stakeIndex invalid");	
        StakeStore storage stRef = stakeLists[stakerAddr][stakeIndex];	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stRef, stakeIdParam, st);	
        /* Stake must have served full term */	
        require(g._currentDay >= st._lockedDay + st._stakedDays, "CSNE: Stake not fully served");	
        /* Stake must still be locked */	
        require(st._unlockedDay == 0, "CSNE: Stake already unlocked");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        /* Unlock the completed stake */	
        _stakeUnlock(g, st);	
        /* stakeReturn & dividends values are unused here */	
        (, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty) = _stakePerformance(	
            g,	
            st,	
            st._stakedDays	
        );	
        emit StakeGoodAccounting(	
            stakeIdParam,	
            stakerAddr,	
            msg.sender,	
            st._stakedSuns,	
            st._stakeShares,	
            payout,	
            penalty	
        );	
        if (cappedPenalty != 0) {	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* st._unlockedDay has changed */	
        _stakeUpdate(stRef, st);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Closes a stake. The order of the stake list can change so	
     * a stake id is used to reject stale indexes.	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeEnd(uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        StakeStore[] storage stakeListRef = stakeLists[msg.sender];	
        /* require() is more informative than the default assert() */	
        require(stakeListRef.length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeListRef.length, "CSNE: stakeIndex invalid");	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stakeListRef[stakeIndex], stakeIdParam, st);	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        uint256 servedDays = 0;	
        bool prevUnlocked = (st._unlockedDay != 0);	
        uint256 stakeReturn;	
        uint256 payout = 0;	
        uint256 dividends = 0;	
        uint256 penalty = 0;	
        uint256 cappedPenalty = 0;	
        if (g._currentDay >= st._lockedDay) {	
            if (prevUnlocked) {	
                /* Previously unlocked in stakeGoodAccounting(), so must have served full term */	
                servedDays = st._stakedDays;	
            } else {	
                _stakeUnlock(g, st);	
                servedDays = g._currentDay - st._lockedDay;	
                if (servedDays > st._stakedDays) {	
                    servedDays = st._stakedDays;	
                }	
            }	
            (stakeReturn, payout, dividends, penalty, cappedPenalty) = _stakePerformance(g, st, servedDays);	
            msg.sender.transfer(dividends);	
        } else {	
            /* Stake hasn't been added to the total yet, so no penalties or rewards apply */	
            g._nextStakeSharesTotal -= st._stakeShares;	
            stakeReturn = st._stakedSuns;	
        }	
        emit StakeEnd(	
            stakeIdParam, 	
            prevUnlocked ? 1 : 0,	
            msg.sender,	
            st._lockedDay,	
            servedDays, 	
            st._stakedSuns, 	
            st._stakeShares, 	
            dividends,	
            payout, 	
            penalty,	
            stakeReturn	
        );	
        if (cappedPenalty != 0 && !prevUnlocked) {	
            /* Split penalty proceeds only if not previously unlocked by stakeGoodAccounting() */	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* Pay the stake return, if any, to the staker */	
        if (stakeReturn != 0) {	
            _mint(msg.sender, stakeReturn);	
            /* Update the share rate if necessary */	
            _shareRateUpdate(g, st, stakeReturn);	
        }	
        g._lockedSunsTotal -= st._stakedSuns;	
        _stakeRemove(stakeListRef, stakeIndex);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the current stake count for a staker address	
     * @param stakerAddr Address of staker	
     */	
    function stakeCount(address stakerAddr)	
        external	
        view	
        returns (uint256)	
    {	
        return stakeLists[stakerAddr].length;	
    }	
    /**	
     * @dev Open a stake.	
     * @param g Cache of stored globals	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStart(	
        GlobalsCache memory g,	
        uint256 newStakedSuns,	
        uint256 newStakedDays	
    )	
        internal	
    {	
        /* Enforce the maximum stake time */	
        require(newStakedDays <= MAX_STAKE_DAYS, "CSNE: newStakedDays higher than maximum");	
        uint256 bonusSuns = _stakeStartBonusSuns(newStakedSuns, newStakedDays);	
        uint256 newStakeShares = (newStakedSuns + bonusSuns) * SHARE_RATE_SCALE / g._shareRate;	
        /* Ensure newStakedSuns is enough for at least one stake share */	
        require(newStakeShares != 0, "CSNE: newStakedSuns must be at least minimum shareRate");	
        /*	
            The stakeStart timestamp will always be part-way through the current	
            day, so it needs to be rounded-up to the next day to ensure all	
            stakes align with the same fixed calendar days. The current day is	
            already rounded-down, so rounded-up is current day + 1.	
        */	
        uint256 newLockedDay = g._currentDay + 1;	
        /* Create Stake */	
        uint40 newStakeId = ++g._latestStakeId;	
        _stakeAdd(	
            stakeLists[msg.sender],	
            newStakeId,	
            newStakedSuns,	
            newStakeShares,	
            newLockedDay,	
            newStakedDays	
        );	
        emit StakeStart(	
            newStakeId, 	
            msg.sender,	
            newStakedSuns, 	
            newStakeShares, 	
            newStakedDays	
        );	
        /* Stake is added to total in the next round, not the current round */	
        g._nextStakeSharesTotal += newStakeShares;	
        /* Track total staked Suns for inflation calculations */	
        g._lockedSunsTotal += newStakedSuns;	
    }	
    /**	
     * @dev Calculates total stake payout including rewards for a multi-day range	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutRewards(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        uint256 counter;	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            dayPayout = dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal;	
            if (counter < 4) {	
                counter++;	
            } 	
            /* Eligible to receive bonus */	
            else {	
                dayPayout = (dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal) * BONUS_DAY_SCALE;	
                counter = 0;	
            }	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculates user dividends	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutDividendsReward(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            /* user's share of 95% of the day's dividends */	
            dayPayout += ((dailyData[day].dayDividends * 95) / 100) * stakeSharesParam	
            / dailyData[day].dayStakeSharesTotal;	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculate bonus Suns for a new stake, if any	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStartBonusSuns(uint256 newStakedSuns, uint256 newStakedDays)	
        private	
        pure	
        returns (uint256 bonusSuns)	
    {	
       
        uint256 cappedExtraDays = 0;	
        /* Must be more than 1 day for Longer-Pays-Better */	
        if (newStakedDays > 1) {	
            cappedExtraDays = newStakedDays <= LPB_MAX_DAYS ? newStakedDays - 1 : LPB_MAX_DAYS;	
        }	
        uint256 cappedStakedSuns = newStakedSuns <= BPB_MAX_SUNS	
            ? newStakedSuns	
            : BPB_MAX_SUNS;	
        bonusSuns = cappedExtraDays * BPB + cappedStakedSuns * LPB;	
        bonusSuns = newStakedSuns * bonusSuns / (LPB * BPB);	
        return bonusSuns;	
    }	
    function _stakeUnlock(GlobalsCache memory g, StakeCache memory st)	
        private	
        pure	
    {	
        g._stakeSharesTotal -= st._stakeShares;	
        st._unlockedDay = g._currentDay;	
    }	
    function _stakePerformance(GlobalsCache memory g, StakeCache memory st, uint256 servedDays)	
        private	
        view	
        returns (uint256 stakeReturn, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty)	
    {	
        if (servedDays < st._stakedDays) {	
            (payout, penalty) = _calcPayoutAndEarlyPenalty(	
                g,	
                st._lockedDay,	
                st._stakedDays,	
                servedDays,	
                st._stakeShares	
            );	
            stakeReturn = st._stakedSuns + payout;	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
        } else {	
            // servedDays must == stakedDays here	
            payout = _calcPayoutRewards(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            stakeReturn = st._stakedSuns + payout;	
            penalty = _calcLatePenalty(st._lockedDay, st._stakedDays, st._unlockedDay, stakeReturn);	
        }	
        if (penalty != 0) {	
            if (penalty > stakeReturn) {	
                /* Cannot have a negative stake return */	
                cappedPenalty = stakeReturn;	
                stakeReturn = 0;	
            } else {	
                /* Remove penalty from the stake return */	
                cappedPenalty = penalty;	
                stakeReturn -= cappedPenalty;	
            }	
        }	
        return (stakeReturn, payout, dividends, penalty, cappedPenalty);	
    }	
    function _calcPayoutAndEarlyPenalty(	
        GlobalsCache memory g,	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 servedDays,	
        uint256 stakeSharesParam	
    )	
        private	
        view	
        returns (uint256 payout, uint256 penalty)	
    {	
        uint256 servedEndDay = lockedDayParam + servedDays;	
        /* 50% of stakedDays (rounded up) with a minimum applied */	
        uint256 penaltyDays = (stakedDaysParam + 1) / 2;	
        if (penaltyDays < EARLY_PENALTY_MIN_DAYS) {	
            penaltyDays = EARLY_PENALTY_MIN_DAYS;	
        }	
        if (servedDays == 0) {	
            /* Fill penalty days with the estimated average payout */	
            uint256 expected = _estimatePayoutRewardsDay(g, stakeSharesParam, lockedDayParam);	
            penalty = expected * penaltyDays;	
            return (payout, penalty); // Actual payout was 0	
        }	
        if (penaltyDays < servedDays) {	
            /*	
                Simplified explanation of intervals where end-day is non-inclusive:	
                penalty:    [lockedDay  ...  penaltyEndDay)	
                delta:                      [penaltyEndDay  ...  servedEndDay)	
                payout:     [lockedDay  .......................  servedEndDay)	
            */	
            uint256 penaltyEndDay = lockedDayParam + penaltyDays;	
            penalty = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, penaltyEndDay);	
            uint256 delta = _calcPayoutRewards(g, stakeSharesParam, penaltyEndDay, servedEndDay);	
            payout = penalty + delta;	
            return (payout, penalty);	
        }	
        /* penaltyDays >= servedDays  */	
        payout = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, servedEndDay);	
        if (penaltyDays == servedDays) {	
            penalty = payout;	
        } else {	
            /*	
                (penaltyDays > servedDays) means not enough days served, so fill the	
                penalty days with the average payout from only the days that were served.	
            */	
            penalty = payout * penaltyDays / servedDays;	
        }	
        return (payout, penalty);	
    }	
    function _calcLatePenalty(	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 unlockedDayParam,	
        uint256 rawStakeReturn	
    )	
        private	
        pure	
        returns (uint256)	
    {	
        /* Allow grace time before penalties accrue */	
        uint256 maxUnlockedDay = lockedDayParam + stakedDaysParam + LATE_PENALTY_GRACE_DAYS;	
        if (unlockedDayParam <= maxUnlockedDay) {	
            return 0;	
        }	
        /* Calculate penalty as a percentage of stake return based on time */	
        return rawStakeReturn * (unlockedDayParam - maxUnlockedDay) / LATE_PENALTY_SCALE_DAYS;	
    }	
    function _shareRateUpdate(GlobalsCache memory g, StakeCache memory st, uint256 stakeReturn)	
        private	
    {	
        if (stakeReturn > st._stakedSuns) {	
            /*	
                Calculate the new shareRate that would yield the same number of shares if	
                the user re-staked this stakeReturn, factoring in any bonuses they would	
                receive in stakeStart().	
            */	
            uint256 bonusSuns = _stakeStartBonusSuns(stakeReturn, st._stakedDays);	
            uint256 newShareRate = (stakeReturn + bonusSuns) * SHARE_RATE_SCALE / st._stakeShares;	
            if (newShareRate > SHARE_RATE_MAX) {	
                /*	
                    Realistically this can't happen, but there are contrived theoretical	
                    scenarios that can lead to extreme values of newShareRate, so it is	
                    capped to prevent them anyway.	
                */	
                newShareRate = SHARE_RATE_MAX;	
            }	
            if (newShareRate > g._shareRate) {	
                g._shareRate = newShareRate;	
                emit ShareRateChange(	
                    st._stakeId,	
                    block.timestamp,	
                    newShareRate	
                );	
            }	
        }	
    }	
} | 
	_calcPayoutDividendsReward | 
	function _calcPayoutDividendsReward(	
    GlobalsCache memory g,	
    uint256 stakeSharesParam,	
    uint256 beginDay,	
    uint256 endDay	
)	
    private	
    view	
    returns (uint256 payout)	
{	
    for (uint256 day = beginDay; day < endDay; day++) {	
        uint256 dayPayout;	
        /* user's share of 95% of the day's dividends */	
        dayPayout += ((dailyData[day].dayDividends * 95) / 100) * stakeSharesParam	
        / dailyData[day].dayStakeSharesTotal;	
        payout += dayPayout;	
    }	
    return payout;	
}	
 | 
	/**	
 * @dev Calculates user dividends	
 * @param g Cache of stored globals	
 * @param stakeSharesParam Param from stake to calculate bonuses for	
 * @param beginDay First day to calculate bonuses for	
 * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
 * @return Payout in Suns	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    10066,
    10693
  ]
} | 4,615 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	StakeableToken | 
	contract StakeableToken is GlobalsAndUtility {	
    /**	
     * @dev PUBLIC FACING: Open a stake.	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function stakeStart(uint256 newStakedSuns, uint256 newStakedDays)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* Enforce the minimum stake time */	
        require(newStakedDays >= MIN_STAKE_DAYS, "CSNE: newStakedDays lower than minimum");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        _stakeStart(g, newStakedSuns, newStakedDays);	
        /* Remove staked Suns from balance of staker */	
        _burn(msg.sender, newStakedSuns);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Unlocks a completed stake, distributing the proceeds of any penalty	
     * immediately. The staker must still call stakeEnd() to retrieve their stake return (if any).	
     * @param stakerAddr Address of staker	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeGoodAccounting(address stakerAddr, uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        /* require() is more informative than the default assert() */	
        require(stakeLists[stakerAddr].length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeLists[stakerAddr].length, "CSNE: stakeIndex invalid");	
        StakeStore storage stRef = stakeLists[stakerAddr][stakeIndex];	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stRef, stakeIdParam, st);	
        /* Stake must have served full term */	
        require(g._currentDay >= st._lockedDay + st._stakedDays, "CSNE: Stake not fully served");	
        /* Stake must still be locked */	
        require(st._unlockedDay == 0, "CSNE: Stake already unlocked");	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        /* Unlock the completed stake */	
        _stakeUnlock(g, st);	
        /* stakeReturn & dividends values are unused here */	
        (, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty) = _stakePerformance(	
            g,	
            st,	
            st._stakedDays	
        );	
        emit StakeGoodAccounting(	
            stakeIdParam,	
            stakerAddr,	
            msg.sender,	
            st._stakedSuns,	
            st._stakeShares,	
            payout,	
            penalty	
        );	
        if (cappedPenalty != 0) {	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* st._unlockedDay has changed */	
        _stakeUpdate(stRef, st);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Closes a stake. The order of the stake list can change so	
     * a stake id is used to reject stale indexes.	
     * @param stakeIndex Index of stake within stake list	
     * @param stakeIdParam The stake's id	
     */	
    function stakeEnd(uint256 stakeIndex, uint40 stakeIdParam)	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        StakeStore[] storage stakeListRef = stakeLists[msg.sender];	
        /* require() is more informative than the default assert() */	
        require(stakeListRef.length != 0, "CSNE: Empty stake list");	
        require(stakeIndex < stakeListRef.length, "CSNE: stakeIndex invalid");	
        /* Get stake copy */	
        StakeCache memory st;	
        _stakeLoad(stakeListRef[stakeIndex], stakeIdParam, st);	
        /* Check if log data needs to be updated */	
        _dailyDataUpdateAuto(g);	
        uint256 servedDays = 0;	
        bool prevUnlocked = (st._unlockedDay != 0);	
        uint256 stakeReturn;	
        uint256 payout = 0;	
        uint256 dividends = 0;	
        uint256 penalty = 0;	
        uint256 cappedPenalty = 0;	
        if (g._currentDay >= st._lockedDay) {	
            if (prevUnlocked) {	
                /* Previously unlocked in stakeGoodAccounting(), so must have served full term */	
                servedDays = st._stakedDays;	
            } else {	
                _stakeUnlock(g, st);	
                servedDays = g._currentDay - st._lockedDay;	
                if (servedDays > st._stakedDays) {	
                    servedDays = st._stakedDays;	
                }	
            }	
            (stakeReturn, payout, dividends, penalty, cappedPenalty) = _stakePerformance(g, st, servedDays);	
            msg.sender.transfer(dividends);	
        } else {	
            /* Stake hasn't been added to the total yet, so no penalties or rewards apply */	
            g._nextStakeSharesTotal -= st._stakeShares;	
            stakeReturn = st._stakedSuns;	
        }	
        emit StakeEnd(	
            stakeIdParam, 	
            prevUnlocked ? 1 : 0,	
            msg.sender,	
            st._lockedDay,	
            servedDays, 	
            st._stakedSuns, 	
            st._stakeShares, 	
            dividends,	
            payout, 	
            penalty,	
            stakeReturn	
        );	
        if (cappedPenalty != 0 && !prevUnlocked) {	
            /* Split penalty proceeds only if not previously unlocked by stakeGoodAccounting() */	
            g._stakePenaltyTotal += cappedPenalty;	
        }	
        /* Pay the stake return, if any, to the staker */	
        if (stakeReturn != 0) {	
            _mint(msg.sender, stakeReturn);	
            /* Update the share rate if necessary */	
            _shareRateUpdate(g, st, stakeReturn);	
        }	
        g._lockedSunsTotal -= st._stakedSuns;	
        _stakeRemove(stakeListRef, stakeIndex);	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the current stake count for a staker address	
     * @param stakerAddr Address of staker	
     */	
    function stakeCount(address stakerAddr)	
        external	
        view	
        returns (uint256)	
    {	
        return stakeLists[stakerAddr].length;	
    }	
    /**	
     * @dev Open a stake.	
     * @param g Cache of stored globals	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStart(	
        GlobalsCache memory g,	
        uint256 newStakedSuns,	
        uint256 newStakedDays	
    )	
        internal	
    {	
        /* Enforce the maximum stake time */	
        require(newStakedDays <= MAX_STAKE_DAYS, "CSNE: newStakedDays higher than maximum");	
        uint256 bonusSuns = _stakeStartBonusSuns(newStakedSuns, newStakedDays);	
        uint256 newStakeShares = (newStakedSuns + bonusSuns) * SHARE_RATE_SCALE / g._shareRate;	
        /* Ensure newStakedSuns is enough for at least one stake share */	
        require(newStakeShares != 0, "CSNE: newStakedSuns must be at least minimum shareRate");	
        /*	
            The stakeStart timestamp will always be part-way through the current	
            day, so it needs to be rounded-up to the next day to ensure all	
            stakes align with the same fixed calendar days. The current day is	
            already rounded-down, so rounded-up is current day + 1.	
        */	
        uint256 newLockedDay = g._currentDay + 1;	
        /* Create Stake */	
        uint40 newStakeId = ++g._latestStakeId;	
        _stakeAdd(	
            stakeLists[msg.sender],	
            newStakeId,	
            newStakedSuns,	
            newStakeShares,	
            newLockedDay,	
            newStakedDays	
        );	
        emit StakeStart(	
            newStakeId, 	
            msg.sender,	
            newStakedSuns, 	
            newStakeShares, 	
            newStakedDays	
        );	
        /* Stake is added to total in the next round, not the current round */	
        g._nextStakeSharesTotal += newStakeShares;	
        /* Track total staked Suns for inflation calculations */	
        g._lockedSunsTotal += newStakedSuns;	
    }	
    /**	
     * @dev Calculates total stake payout including rewards for a multi-day range	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutRewards(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        uint256 counter;	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            dayPayout = dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal;	
            if (counter < 4) {	
                counter++;	
            } 	
            /* Eligible to receive bonus */	
            else {	
                dayPayout = (dailyData[day].dayPayoutTotal * stakeSharesParam	
                / dailyData[day].dayStakeSharesTotal) * BONUS_DAY_SCALE;	
                counter = 0;	
            }	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculates user dividends	
     * @param g Cache of stored globals	
     * @param stakeSharesParam Param from stake to calculate bonuses for	
     * @param beginDay First day to calculate bonuses for	
     * @param endDay Last day (non-inclusive) of range to calculate bonuses for	
     * @return Payout in Suns	
     */	
    function _calcPayoutDividendsReward(	
        GlobalsCache memory g,	
        uint256 stakeSharesParam,	
        uint256 beginDay,	
        uint256 endDay	
    )	
        private	
        view	
        returns (uint256 payout)	
    {	
        for (uint256 day = beginDay; day < endDay; day++) {	
            uint256 dayPayout;	
            /* user's share of 95% of the day's dividends */	
            dayPayout += ((dailyData[day].dayDividends * 95) / 100) * stakeSharesParam	
            / dailyData[day].dayStakeSharesTotal;	
            payout += dayPayout;	
        }	
        return payout;	
    }	
    /**	
     * @dev Calculate bonus Suns for a new stake, if any	
     * @param newStakedSuns Number of Suns to stake	
     * @param newStakedDays Number of days to stake	
     */	
    function _stakeStartBonusSuns(uint256 newStakedSuns, uint256 newStakedDays)	
        private	
        pure	
        returns (uint256 bonusSuns)	
    {	
       
        uint256 cappedExtraDays = 0;	
        /* Must be more than 1 day for Longer-Pays-Better */	
        if (newStakedDays > 1) {	
            cappedExtraDays = newStakedDays <= LPB_MAX_DAYS ? newStakedDays - 1 : LPB_MAX_DAYS;	
        }	
        uint256 cappedStakedSuns = newStakedSuns <= BPB_MAX_SUNS	
            ? newStakedSuns	
            : BPB_MAX_SUNS;	
        bonusSuns = cappedExtraDays * BPB + cappedStakedSuns * LPB;	
        bonusSuns = newStakedSuns * bonusSuns / (LPB * BPB);	
        return bonusSuns;	
    }	
    function _stakeUnlock(GlobalsCache memory g, StakeCache memory st)	
        private	
        pure	
    {	
        g._stakeSharesTotal -= st._stakeShares;	
        st._unlockedDay = g._currentDay;	
    }	
    function _stakePerformance(GlobalsCache memory g, StakeCache memory st, uint256 servedDays)	
        private	
        view	
        returns (uint256 stakeReturn, uint256 payout, uint256 dividends, uint256 penalty, uint256 cappedPenalty)	
    {	
        if (servedDays < st._stakedDays) {	
            (payout, penalty) = _calcPayoutAndEarlyPenalty(	
                g,	
                st._lockedDay,	
                st._stakedDays,	
                servedDays,	
                st._stakeShares	
            );	
            stakeReturn = st._stakedSuns + payout;	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
        } else {	
            // servedDays must == stakedDays here	
            payout = _calcPayoutRewards(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            dividends = _calcPayoutDividendsReward(	
                g,	
                st._stakeShares,	
                st._lockedDay,	
                st._lockedDay + servedDays	
            );	
            stakeReturn = st._stakedSuns + payout;	
            penalty = _calcLatePenalty(st._lockedDay, st._stakedDays, st._unlockedDay, stakeReturn);	
        }	
        if (penalty != 0) {	
            if (penalty > stakeReturn) {	
                /* Cannot have a negative stake return */	
                cappedPenalty = stakeReturn;	
                stakeReturn = 0;	
            } else {	
                /* Remove penalty from the stake return */	
                cappedPenalty = penalty;	
                stakeReturn -= cappedPenalty;	
            }	
        }	
        return (stakeReturn, payout, dividends, penalty, cappedPenalty);	
    }	
    function _calcPayoutAndEarlyPenalty(	
        GlobalsCache memory g,	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 servedDays,	
        uint256 stakeSharesParam	
    )	
        private	
        view	
        returns (uint256 payout, uint256 penalty)	
    {	
        uint256 servedEndDay = lockedDayParam + servedDays;	
        /* 50% of stakedDays (rounded up) with a minimum applied */	
        uint256 penaltyDays = (stakedDaysParam + 1) / 2;	
        if (penaltyDays < EARLY_PENALTY_MIN_DAYS) {	
            penaltyDays = EARLY_PENALTY_MIN_DAYS;	
        }	
        if (servedDays == 0) {	
            /* Fill penalty days with the estimated average payout */	
            uint256 expected = _estimatePayoutRewardsDay(g, stakeSharesParam, lockedDayParam);	
            penalty = expected * penaltyDays;	
            return (payout, penalty); // Actual payout was 0	
        }	
        if (penaltyDays < servedDays) {	
            /*	
                Simplified explanation of intervals where end-day is non-inclusive:	
                penalty:    [lockedDay  ...  penaltyEndDay)	
                delta:                      [penaltyEndDay  ...  servedEndDay)	
                payout:     [lockedDay  .......................  servedEndDay)	
            */	
            uint256 penaltyEndDay = lockedDayParam + penaltyDays;	
            penalty = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, penaltyEndDay);	
            uint256 delta = _calcPayoutRewards(g, stakeSharesParam, penaltyEndDay, servedEndDay);	
            payout = penalty + delta;	
            return (payout, penalty);	
        }	
        /* penaltyDays >= servedDays  */	
        payout = _calcPayoutRewards(g, stakeSharesParam, lockedDayParam, servedEndDay);	
        if (penaltyDays == servedDays) {	
            penalty = payout;	
        } else {	
            /*	
                (penaltyDays > servedDays) means not enough days served, so fill the	
                penalty days with the average payout from only the days that were served.	
            */	
            penalty = payout * penaltyDays / servedDays;	
        }	
        return (payout, penalty);	
    }	
    function _calcLatePenalty(	
        uint256 lockedDayParam,	
        uint256 stakedDaysParam,	
        uint256 unlockedDayParam,	
        uint256 rawStakeReturn	
    )	
        private	
        pure	
        returns (uint256)	
    {	
        /* Allow grace time before penalties accrue */	
        uint256 maxUnlockedDay = lockedDayParam + stakedDaysParam + LATE_PENALTY_GRACE_DAYS;	
        if (unlockedDayParam <= maxUnlockedDay) {	
            return 0;	
        }	
        /* Calculate penalty as a percentage of stake return based on time */	
        return rawStakeReturn * (unlockedDayParam - maxUnlockedDay) / LATE_PENALTY_SCALE_DAYS;	
    }	
    function _shareRateUpdate(GlobalsCache memory g, StakeCache memory st, uint256 stakeReturn)	
        private	
    {	
        if (stakeReturn > st._stakedSuns) {	
            /*	
                Calculate the new shareRate that would yield the same number of shares if	
                the user re-staked this stakeReturn, factoring in any bonuses they would	
                receive in stakeStart().	
            */	
            uint256 bonusSuns = _stakeStartBonusSuns(stakeReturn, st._stakedDays);	
            uint256 newShareRate = (stakeReturn + bonusSuns) * SHARE_RATE_SCALE / st._stakeShares;	
            if (newShareRate > SHARE_RATE_MAX) {	
                /*	
                    Realistically this can't happen, but there are contrived theoretical	
                    scenarios that can lead to extreme values of newShareRate, so it is	
                    capped to prevent them anyway.	
                */	
                newShareRate = SHARE_RATE_MAX;	
            }	
            if (newShareRate > g._shareRate) {	
                g._shareRate = newShareRate;	
                emit ShareRateChange(	
                    st._stakeId,	
                    block.timestamp,	
                    newShareRate	
                );	
            }	
        }	
    }	
} | 
	_stakeStartBonusSuns | 
	function _stakeStartBonusSuns(uint256 newStakedSuns, uint256 newStakedDays)	
    private	
    pure	
    returns (uint256 bonusSuns)	
{	
       
    uint256 cappedExtraDays = 0;	
    /* Must be more than 1 day for Longer-Pays-Better */	
    if (newStakedDays > 1) {	
        cappedExtraDays = newStakedDays <= LPB_MAX_DAYS ? newStakedDays - 1 : LPB_MAX_DAYS;	
    }	
    uint256 cappedStakedSuns = newStakedSuns <= BPB_MAX_SUNS	
        ? newStakedSuns	
        : BPB_MAX_SUNS;	
    bonusSuns = cappedExtraDays * BPB + cappedStakedSuns * LPB;	
    bonusSuns = newStakedSuns * bonusSuns / (LPB * BPB);	
    return bonusSuns;	
}	
 | 
	/**	
 * @dev Calculate bonus Suns for a new stake, if any	
 * @param newStakedSuns Number of Suns to stake	
 * @param newStakedDays Number of days to stake	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    10881,
    11593
  ]
} | 4,616 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	TransformableToken | 
	contract TransformableToken is StakeableToken {	
    /**	
     * @dev PUBLIC FACING: Enter the auction lobby for the current round	
     * @param referrerAddr TRX address of referring user (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEnter(address referrerAddr)	
        external	
        payable	
    {	
	require(_currentDay() > 0, "CSNE: Auction has not begun yet");	
        uint256 enterDay = _currentDay();	
        uint256 rawAmount = msg.value;	
        require(rawAmount != 0, "CSNE: Amount required");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 entryIndex = qRef.tailIndex++;	
        qRef.entries[entryIndex] = XfLobbyEntryStore(uint96(rawAmount), referrerAddr);	
        xfLobby[enterDay] += rawAmount;	
        emit XfLobbyEnter(	
            block.timestamp, 	
            enterDay, 	
            entryIndex, 	
            rawAmount	
        );	
    }	
    /**	
     * @dev PUBLIC FACING: Leave the transform lobby after the round is complete	
     * @param enterDay Day number when the member entered	
     * @param count Number of queued-enters to exit (optional; 0 for all)	
     */	
    function xfLobbyExit(uint256 enterDay, uint256 count)	
        external	
    {	
        require(enterDay < _currentDay(), "CSNE: Round is not complete");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 headIndex = qRef.headIndex;	
        uint256 endIndex;	
        if (count != 0) {	
            require(count <= qRef.tailIndex - headIndex, "CSNE: count invalid");	
            endIndex = headIndex + count;	
        } else {	
            endIndex = qRef.tailIndex;	
            require(headIndex < endIndex, "CSNE: count invalid");	
        }	
        uint256 waasLobby = _waasLobby(enterDay);	
        uint256 _xfLobby = xfLobby[enterDay];	
        uint256 totalXfAmount = 0;	
        do {	
            uint256 rawAmount = qRef.entries[headIndex].rawAmount;	
            address referrerAddr = qRef.entries[headIndex].referrerAddr;	
            delete qRef.entries[headIndex];	
            uint256 xfAmount = waasLobby * rawAmount / _xfLobby;	
            if (referrerAddr == address(0) || referrerAddr == msg.sender) {	
                /* No referrer or Self-referred */	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
            } else {	
                /* Referral bonus of 5% of xfAmount to member */	
                uint256 referralBonusSuns = xfAmount / 20;	
                xfAmount += referralBonusSuns;	
                /* Then a cumulative referrer bonus of 10% to referrer */	
                uint256 referrerBonusSuns = xfAmount / 10;	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
                _mint(referrerAddr, referrerBonusSuns);	
            }	
            totalXfAmount += xfAmount;	
        } while (++headIndex < endIndex);	
        qRef.headIndex = uint40(headIndex);	
        if (totalXfAmount != 0) {	
            _mint(msg.sender, totalXfAmount);	
        }	
    }	
    /**	
     * @dev PUBLIC FACING: External helper to return multiple values of xfLobby[] with	
     * a single call	
     * @param beginDay First day of data range	
     * @param endDay Last day (non-inclusive) of data range	
     * @return Fixed array of values	
     */	
    function xfLobbyRange(uint256 beginDay, uint256 endDay)	
        external	
        view	
        returns (uint256[] memory list)	
    {	
        require(	
            beginDay < endDay && endDay <= _currentDay(),	
            "CSNE: invalid range"	
        );	
        list = new uint256[](endDay - beginDay);	
        uint256 src = beginDay;	
        uint256 dst = 0;	
        do {	
            list[dst++] = uint256(xfLobby[src++]);	
        } while (src < endDay);	
        return list;	
    }	
    /**	
     * @dev PUBLIC FACING: Release 5% share from daily dividends for Website Maintenance and to add liquidity for Tokens in JustSwap Listing to support community	
     */	
    function xfFlush()	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        	
        require(address(this).balance != 0, "CSNE: No value");	
        require(LAST_FLUSHED_DAY < _currentDay(), "CSNE: Invalid day");	
        _dailyDataUpdateAuto(g);	
        FLUSH_ADDR.transfer((dailyData[LAST_FLUSHED_DAY].dayDividends * 5) / 100);	
        LAST_FLUSHED_DAY++;	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return a current lobby member queue entry.	
     * Only needed due to limitations of the standard ABI encoder.	
     * @param entryIndex Entries to index	
     * @param enterDay Day number when the member entered	
     * @param memberAddr TRX address of the lobby member	
     * @return 1: Raw amount that was entered with; 2: Referring TRX addr (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEntry(address memberAddr, uint256 enterDay, uint256 entryIndex)	
        external	
        view	
        returns (uint256 rawAmount, address referrerAddr)	
    {	
        XfLobbyEntryStore storage entry = xfLobbyMembers[enterDay][memberAddr].entries[entryIndex];	
        require(entry.rawAmount != 0, "CSNE: Param invalid");	
        return (entry.rawAmount, entry.referrerAddr);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the lobby days that a user is in with a single call	
     * @param memberAddr TRX address of the user	
     * @return Bit vector of lobby day numbers	
     */	
    function xfLobbyPendingDays(address memberAddr)	
        external	
        view	
        returns (uint256[XF_LOBBY_DAY_WORDS] memory words)	
    {	
        uint256 day = _currentDay() + 1;	
        while (day-- != 0) {	
            if (xfLobbyMembers[day][memberAddr].tailIndex > xfLobbyMembers[day][memberAddr].headIndex) {	
                words[day >> 8] |= 1 << (day & 255);	
            }	
        }	
        return words;	
    }	
    	
    function _waasLobby(uint256 enterDay)	
        private	
        returns (uint256 waasLobby)	
    {
                /* 410958904109  = ~ 1500000 * SUNS_PER_DIV /365  */	
        if (enterDay > 0 && enterDay <= 365) {                                     	
            waasLobby = CLAIM_STARTING_AMOUNT - ((enterDay - 1) * 410958904109);
        } else {
            waasLobby = CLAIM_LOWEST_AMOUNT;
        }
        return waasLobby;
    }
    function _emitXfLobbyExit(
        uint256 enterDay,
        uint256 entryIndex,
        uint256 xfAmount,
        address referrerAddr
    )
        private
    {
        emit XfLobbyExit(
            block.timestamp, 
            enterDay,
            entryIndex,
            xfAmount,
            referrerAddr
        );
    }
} | 
	xfLobbyEnter | 
	function xfLobbyEnter(address referrerAddr)	
    external	
    payable	
{	
uire(_currentDay() > 0, "CSNE: Auction has not begun yet");	
    uint256 enterDay = _currentDay();	
    uint256 rawAmount = msg.value;	
    require(rawAmount != 0, "CSNE: Amount required");	
    XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
    uint256 entryIndex = qRef.tailIndex++;	
    qRef.entries[entryIndex] = XfLobbyEntryStore(uint96(rawAmount), referrerAddr);	
    xfLobby[enterDay] += rawAmount;	
    emit XfLobbyEnter(	
        block.timestamp, 	
        enterDay, 	
        entryIndex, 	
        rawAmount	
    );	
}	
 | 
	/**	
 * @dev PUBLIC FACING: Enter the auction lobby for the current round	
 * @param referrerAddr TRX address of referring user (optional; 0x0 for no referrer)	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    236,
    960
  ]
} | 4,617 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	TransformableToken | 
	contract TransformableToken is StakeableToken {	
    /**	
     * @dev PUBLIC FACING: Enter the auction lobby for the current round	
     * @param referrerAddr TRX address of referring user (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEnter(address referrerAddr)	
        external	
        payable	
    {	
	require(_currentDay() > 0, "CSNE: Auction has not begun yet");	
        uint256 enterDay = _currentDay();	
        uint256 rawAmount = msg.value;	
        require(rawAmount != 0, "CSNE: Amount required");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 entryIndex = qRef.tailIndex++;	
        qRef.entries[entryIndex] = XfLobbyEntryStore(uint96(rawAmount), referrerAddr);	
        xfLobby[enterDay] += rawAmount;	
        emit XfLobbyEnter(	
            block.timestamp, 	
            enterDay, 	
            entryIndex, 	
            rawAmount	
        );	
    }	
    /**	
     * @dev PUBLIC FACING: Leave the transform lobby after the round is complete	
     * @param enterDay Day number when the member entered	
     * @param count Number of queued-enters to exit (optional; 0 for all)	
     */	
    function xfLobbyExit(uint256 enterDay, uint256 count)	
        external	
    {	
        require(enterDay < _currentDay(), "CSNE: Round is not complete");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 headIndex = qRef.headIndex;	
        uint256 endIndex;	
        if (count != 0) {	
            require(count <= qRef.tailIndex - headIndex, "CSNE: count invalid");	
            endIndex = headIndex + count;	
        } else {	
            endIndex = qRef.tailIndex;	
            require(headIndex < endIndex, "CSNE: count invalid");	
        }	
        uint256 waasLobby = _waasLobby(enterDay);	
        uint256 _xfLobby = xfLobby[enterDay];	
        uint256 totalXfAmount = 0;	
        do {	
            uint256 rawAmount = qRef.entries[headIndex].rawAmount;	
            address referrerAddr = qRef.entries[headIndex].referrerAddr;	
            delete qRef.entries[headIndex];	
            uint256 xfAmount = waasLobby * rawAmount / _xfLobby;	
            if (referrerAddr == address(0) || referrerAddr == msg.sender) {	
                /* No referrer or Self-referred */	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
            } else {	
                /* Referral bonus of 5% of xfAmount to member */	
                uint256 referralBonusSuns = xfAmount / 20;	
                xfAmount += referralBonusSuns;	
                /* Then a cumulative referrer bonus of 10% to referrer */	
                uint256 referrerBonusSuns = xfAmount / 10;	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
                _mint(referrerAddr, referrerBonusSuns);	
            }	
            totalXfAmount += xfAmount;	
        } while (++headIndex < endIndex);	
        qRef.headIndex = uint40(headIndex);	
        if (totalXfAmount != 0) {	
            _mint(msg.sender, totalXfAmount);	
        }	
    }	
    /**	
     * @dev PUBLIC FACING: External helper to return multiple values of xfLobby[] with	
     * a single call	
     * @param beginDay First day of data range	
     * @param endDay Last day (non-inclusive) of data range	
     * @return Fixed array of values	
     */	
    function xfLobbyRange(uint256 beginDay, uint256 endDay)	
        external	
        view	
        returns (uint256[] memory list)	
    {	
        require(	
            beginDay < endDay && endDay <= _currentDay(),	
            "CSNE: invalid range"	
        );	
        list = new uint256[](endDay - beginDay);	
        uint256 src = beginDay;	
        uint256 dst = 0;	
        do {	
            list[dst++] = uint256(xfLobby[src++]);	
        } while (src < endDay);	
        return list;	
    }	
    /**	
     * @dev PUBLIC FACING: Release 5% share from daily dividends for Website Maintenance and to add liquidity for Tokens in JustSwap Listing to support community	
     */	
    function xfFlush()	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        	
        require(address(this).balance != 0, "CSNE: No value");	
        require(LAST_FLUSHED_DAY < _currentDay(), "CSNE: Invalid day");	
        _dailyDataUpdateAuto(g);	
        FLUSH_ADDR.transfer((dailyData[LAST_FLUSHED_DAY].dayDividends * 5) / 100);	
        LAST_FLUSHED_DAY++;	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return a current lobby member queue entry.	
     * Only needed due to limitations of the standard ABI encoder.	
     * @param entryIndex Entries to index	
     * @param enterDay Day number when the member entered	
     * @param memberAddr TRX address of the lobby member	
     * @return 1: Raw amount that was entered with; 2: Referring TRX addr (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEntry(address memberAddr, uint256 enterDay, uint256 entryIndex)	
        external	
        view	
        returns (uint256 rawAmount, address referrerAddr)	
    {	
        XfLobbyEntryStore storage entry = xfLobbyMembers[enterDay][memberAddr].entries[entryIndex];	
        require(entry.rawAmount != 0, "CSNE: Param invalid");	
        return (entry.rawAmount, entry.referrerAddr);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the lobby days that a user is in with a single call	
     * @param memberAddr TRX address of the user	
     * @return Bit vector of lobby day numbers	
     */	
    function xfLobbyPendingDays(address memberAddr)	
        external	
        view	
        returns (uint256[XF_LOBBY_DAY_WORDS] memory words)	
    {	
        uint256 day = _currentDay() + 1;	
        while (day-- != 0) {	
            if (xfLobbyMembers[day][memberAddr].tailIndex > xfLobbyMembers[day][memberAddr].headIndex) {	
                words[day >> 8] |= 1 << (day & 255);	
            }	
        }	
        return words;	
    }	
    	
    function _waasLobby(uint256 enterDay)	
        private	
        returns (uint256 waasLobby)	
    {
                /* 410958904109  = ~ 1500000 * SUNS_PER_DIV /365  */	
        if (enterDay > 0 && enterDay <= 365) {                                     	
            waasLobby = CLAIM_STARTING_AMOUNT - ((enterDay - 1) * 410958904109);
        } else {
            waasLobby = CLAIM_LOWEST_AMOUNT;
        }
        return waasLobby;
    }
    function _emitXfLobbyExit(
        uint256 enterDay,
        uint256 entryIndex,
        uint256 xfAmount,
        address referrerAddr
    )
        private
    {
        emit XfLobbyExit(
            block.timestamp, 
            enterDay,
            entryIndex,
            xfAmount,
            referrerAddr
        );
    }
} | 
	xfLobbyExit | 
	function xfLobbyExit(uint256 enterDay, uint256 count)	
    external	
{	
    require(enterDay < _currentDay(), "CSNE: Round is not complete");	
    XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
    uint256 headIndex = qRef.headIndex;	
    uint256 endIndex;	
    if (count != 0) {	
        require(count <= qRef.tailIndex - headIndex, "CSNE: count invalid");	
        endIndex = headIndex + count;	
    } else {	
        endIndex = qRef.tailIndex;	
        require(headIndex < endIndex, "CSNE: count invalid");	
    }	
    uint256 waasLobby = _waasLobby(enterDay);	
    uint256 _xfLobby = xfLobby[enterDay];	
    uint256 totalXfAmount = 0;	
    do {	
        uint256 rawAmount = qRef.entries[headIndex].rawAmount;	
        address referrerAddr = qRef.entries[headIndex].referrerAddr;	
        delete qRef.entries[headIndex];	
        uint256 xfAmount = waasLobby * rawAmount / _xfLobby;	
        if (referrerAddr == address(0) || referrerAddr == msg.sender) {	
            /* No referrer or Self-referred */	
            _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
        } else {	
            /* Referral bonus of 5% of xfAmount to member */	
            uint256 referralBonusSuns = xfAmount / 20;	
            xfAmount += referralBonusSuns;	
            /* Then a cumulative referrer bonus of 10% to referrer */	
            uint256 referrerBonusSuns = xfAmount / 10;	
            _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
            _mint(referrerAddr, referrerBonusSuns);	
        }	
        totalXfAmount += xfAmount;	
    } while (++headIndex < endIndex);	
    qRef.headIndex = uint40(headIndex);	
    if (totalXfAmount != 0) {	
        _mint(msg.sender, totalXfAmount);	
    }	
}	
 | 
	/**	
 * @dev PUBLIC FACING: Leave the transform lobby after the round is complete	
 * @param enterDay Day number when the member entered	
 * @param count Number of queued-enters to exit (optional; 0 for all)	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    1200,
    3160
  ]
} | 4,618 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	TransformableToken | 
	contract TransformableToken is StakeableToken {	
    /**	
     * @dev PUBLIC FACING: Enter the auction lobby for the current round	
     * @param referrerAddr TRX address of referring user (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEnter(address referrerAddr)	
        external	
        payable	
    {	
	require(_currentDay() > 0, "CSNE: Auction has not begun yet");	
        uint256 enterDay = _currentDay();	
        uint256 rawAmount = msg.value;	
        require(rawAmount != 0, "CSNE: Amount required");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 entryIndex = qRef.tailIndex++;	
        qRef.entries[entryIndex] = XfLobbyEntryStore(uint96(rawAmount), referrerAddr);	
        xfLobby[enterDay] += rawAmount;	
        emit XfLobbyEnter(	
            block.timestamp, 	
            enterDay, 	
            entryIndex, 	
            rawAmount	
        );	
    }	
    /**	
     * @dev PUBLIC FACING: Leave the transform lobby after the round is complete	
     * @param enterDay Day number when the member entered	
     * @param count Number of queued-enters to exit (optional; 0 for all)	
     */	
    function xfLobbyExit(uint256 enterDay, uint256 count)	
        external	
    {	
        require(enterDay < _currentDay(), "CSNE: Round is not complete");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 headIndex = qRef.headIndex;	
        uint256 endIndex;	
        if (count != 0) {	
            require(count <= qRef.tailIndex - headIndex, "CSNE: count invalid");	
            endIndex = headIndex + count;	
        } else {	
            endIndex = qRef.tailIndex;	
            require(headIndex < endIndex, "CSNE: count invalid");	
        }	
        uint256 waasLobby = _waasLobby(enterDay);	
        uint256 _xfLobby = xfLobby[enterDay];	
        uint256 totalXfAmount = 0;	
        do {	
            uint256 rawAmount = qRef.entries[headIndex].rawAmount;	
            address referrerAddr = qRef.entries[headIndex].referrerAddr;	
            delete qRef.entries[headIndex];	
            uint256 xfAmount = waasLobby * rawAmount / _xfLobby;	
            if (referrerAddr == address(0) || referrerAddr == msg.sender) {	
                /* No referrer or Self-referred */	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
            } else {	
                /* Referral bonus of 5% of xfAmount to member */	
                uint256 referralBonusSuns = xfAmount / 20;	
                xfAmount += referralBonusSuns;	
                /* Then a cumulative referrer bonus of 10% to referrer */	
                uint256 referrerBonusSuns = xfAmount / 10;	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
                _mint(referrerAddr, referrerBonusSuns);	
            }	
            totalXfAmount += xfAmount;	
        } while (++headIndex < endIndex);	
        qRef.headIndex = uint40(headIndex);	
        if (totalXfAmount != 0) {	
            _mint(msg.sender, totalXfAmount);	
        }	
    }	
    /**	
     * @dev PUBLIC FACING: External helper to return multiple values of xfLobby[] with	
     * a single call	
     * @param beginDay First day of data range	
     * @param endDay Last day (non-inclusive) of data range	
     * @return Fixed array of values	
     */	
    function xfLobbyRange(uint256 beginDay, uint256 endDay)	
        external	
        view	
        returns (uint256[] memory list)	
    {	
        require(	
            beginDay < endDay && endDay <= _currentDay(),	
            "CSNE: invalid range"	
        );	
        list = new uint256[](endDay - beginDay);	
        uint256 src = beginDay;	
        uint256 dst = 0;	
        do {	
            list[dst++] = uint256(xfLobby[src++]);	
        } while (src < endDay);	
        return list;	
    }	
    /**	
     * @dev PUBLIC FACING: Release 5% share from daily dividends for Website Maintenance and to add liquidity for Tokens in JustSwap Listing to support community	
     */	
    function xfFlush()	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        	
        require(address(this).balance != 0, "CSNE: No value");	
        require(LAST_FLUSHED_DAY < _currentDay(), "CSNE: Invalid day");	
        _dailyDataUpdateAuto(g);	
        FLUSH_ADDR.transfer((dailyData[LAST_FLUSHED_DAY].dayDividends * 5) / 100);	
        LAST_FLUSHED_DAY++;	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return a current lobby member queue entry.	
     * Only needed due to limitations of the standard ABI encoder.	
     * @param entryIndex Entries to index	
     * @param enterDay Day number when the member entered	
     * @param memberAddr TRX address of the lobby member	
     * @return 1: Raw amount that was entered with; 2: Referring TRX addr (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEntry(address memberAddr, uint256 enterDay, uint256 entryIndex)	
        external	
        view	
        returns (uint256 rawAmount, address referrerAddr)	
    {	
        XfLobbyEntryStore storage entry = xfLobbyMembers[enterDay][memberAddr].entries[entryIndex];	
        require(entry.rawAmount != 0, "CSNE: Param invalid");	
        return (entry.rawAmount, entry.referrerAddr);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the lobby days that a user is in with a single call	
     * @param memberAddr TRX address of the user	
     * @return Bit vector of lobby day numbers	
     */	
    function xfLobbyPendingDays(address memberAddr)	
        external	
        view	
        returns (uint256[XF_LOBBY_DAY_WORDS] memory words)	
    {	
        uint256 day = _currentDay() + 1;	
        while (day-- != 0) {	
            if (xfLobbyMembers[day][memberAddr].tailIndex > xfLobbyMembers[day][memberAddr].headIndex) {	
                words[day >> 8] |= 1 << (day & 255);	
            }	
        }	
        return words;	
    }	
    	
    function _waasLobby(uint256 enterDay)	
        private	
        returns (uint256 waasLobby)	
    {
                /* 410958904109  = ~ 1500000 * SUNS_PER_DIV /365  */	
        if (enterDay > 0 && enterDay <= 365) {                                     	
            waasLobby = CLAIM_STARTING_AMOUNT - ((enterDay - 1) * 410958904109);
        } else {
            waasLobby = CLAIM_LOWEST_AMOUNT;
        }
        return waasLobby;
    }
    function _emitXfLobbyExit(
        uint256 enterDay,
        uint256 entryIndex,
        uint256 xfAmount,
        address referrerAddr
    )
        private
    {
        emit XfLobbyExit(
            block.timestamp, 
            enterDay,
            entryIndex,
            xfAmount,
            referrerAddr
        );
    }
} | 
	xfLobbyRange | 
	function xfLobbyRange(uint256 beginDay, uint256 endDay)	
    external	
    view	
    returns (uint256[] memory list)	
{	
    require(	
        beginDay < endDay && endDay <= _currentDay(),	
        "CSNE: invalid range"	
    );	
    list = new uint256[](endDay - beginDay);	
    uint256 src = beginDay;	
    uint256 dst = 0;	
    do {	
        list[dst++] = uint256(xfLobby[src++]);	
    } while (src < endDay);	
    return list;	
}	
 | 
	/**	
 * @dev PUBLIC FACING: External helper to return multiple values of xfLobby[] with	
 * a single call	
 * @param beginDay First day of data range	
 * @param endDay Last day (non-inclusive) of data range	
 * @return Fixed array of values	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    3443,
    3961
  ]
} | 4,619 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	TransformableToken | 
	contract TransformableToken is StakeableToken {	
    /**	
     * @dev PUBLIC FACING: Enter the auction lobby for the current round	
     * @param referrerAddr TRX address of referring user (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEnter(address referrerAddr)	
        external	
        payable	
    {	
	require(_currentDay() > 0, "CSNE: Auction has not begun yet");	
        uint256 enterDay = _currentDay();	
        uint256 rawAmount = msg.value;	
        require(rawAmount != 0, "CSNE: Amount required");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 entryIndex = qRef.tailIndex++;	
        qRef.entries[entryIndex] = XfLobbyEntryStore(uint96(rawAmount), referrerAddr);	
        xfLobby[enterDay] += rawAmount;	
        emit XfLobbyEnter(	
            block.timestamp, 	
            enterDay, 	
            entryIndex, 	
            rawAmount	
        );	
    }	
    /**	
     * @dev PUBLIC FACING: Leave the transform lobby after the round is complete	
     * @param enterDay Day number when the member entered	
     * @param count Number of queued-enters to exit (optional; 0 for all)	
     */	
    function xfLobbyExit(uint256 enterDay, uint256 count)	
        external	
    {	
        require(enterDay < _currentDay(), "CSNE: Round is not complete");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 headIndex = qRef.headIndex;	
        uint256 endIndex;	
        if (count != 0) {	
            require(count <= qRef.tailIndex - headIndex, "CSNE: count invalid");	
            endIndex = headIndex + count;	
        } else {	
            endIndex = qRef.tailIndex;	
            require(headIndex < endIndex, "CSNE: count invalid");	
        }	
        uint256 waasLobby = _waasLobby(enterDay);	
        uint256 _xfLobby = xfLobby[enterDay];	
        uint256 totalXfAmount = 0;	
        do {	
            uint256 rawAmount = qRef.entries[headIndex].rawAmount;	
            address referrerAddr = qRef.entries[headIndex].referrerAddr;	
            delete qRef.entries[headIndex];	
            uint256 xfAmount = waasLobby * rawAmount / _xfLobby;	
            if (referrerAddr == address(0) || referrerAddr == msg.sender) {	
                /* No referrer or Self-referred */	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
            } else {	
                /* Referral bonus of 5% of xfAmount to member */	
                uint256 referralBonusSuns = xfAmount / 20;	
                xfAmount += referralBonusSuns;	
                /* Then a cumulative referrer bonus of 10% to referrer */	
                uint256 referrerBonusSuns = xfAmount / 10;	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
                _mint(referrerAddr, referrerBonusSuns);	
            }	
            totalXfAmount += xfAmount;	
        } while (++headIndex < endIndex);	
        qRef.headIndex = uint40(headIndex);	
        if (totalXfAmount != 0) {	
            _mint(msg.sender, totalXfAmount);	
        }	
    }	
    /**	
     * @dev PUBLIC FACING: External helper to return multiple values of xfLobby[] with	
     * a single call	
     * @param beginDay First day of data range	
     * @param endDay Last day (non-inclusive) of data range	
     * @return Fixed array of values	
     */	
    function xfLobbyRange(uint256 beginDay, uint256 endDay)	
        external	
        view	
        returns (uint256[] memory list)	
    {	
        require(	
            beginDay < endDay && endDay <= _currentDay(),	
            "CSNE: invalid range"	
        );	
        list = new uint256[](endDay - beginDay);	
        uint256 src = beginDay;	
        uint256 dst = 0;	
        do {	
            list[dst++] = uint256(xfLobby[src++]);	
        } while (src < endDay);	
        return list;	
    }	
    /**	
     * @dev PUBLIC FACING: Release 5% share from daily dividends for Website Maintenance and to add liquidity for Tokens in JustSwap Listing to support community	
     */	
    function xfFlush()	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        	
        require(address(this).balance != 0, "CSNE: No value");	
        require(LAST_FLUSHED_DAY < _currentDay(), "CSNE: Invalid day");	
        _dailyDataUpdateAuto(g);	
        FLUSH_ADDR.transfer((dailyData[LAST_FLUSHED_DAY].dayDividends * 5) / 100);	
        LAST_FLUSHED_DAY++;	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return a current lobby member queue entry.	
     * Only needed due to limitations of the standard ABI encoder.	
     * @param entryIndex Entries to index	
     * @param enterDay Day number when the member entered	
     * @param memberAddr TRX address of the lobby member	
     * @return 1: Raw amount that was entered with; 2: Referring TRX addr (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEntry(address memberAddr, uint256 enterDay, uint256 entryIndex)	
        external	
        view	
        returns (uint256 rawAmount, address referrerAddr)	
    {	
        XfLobbyEntryStore storage entry = xfLobbyMembers[enterDay][memberAddr].entries[entryIndex];	
        require(entry.rawAmount != 0, "CSNE: Param invalid");	
        return (entry.rawAmount, entry.referrerAddr);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the lobby days that a user is in with a single call	
     * @param memberAddr TRX address of the user	
     * @return Bit vector of lobby day numbers	
     */	
    function xfLobbyPendingDays(address memberAddr)	
        external	
        view	
        returns (uint256[XF_LOBBY_DAY_WORDS] memory words)	
    {	
        uint256 day = _currentDay() + 1;	
        while (day-- != 0) {	
            if (xfLobbyMembers[day][memberAddr].tailIndex > xfLobbyMembers[day][memberAddr].headIndex) {	
                words[day >> 8] |= 1 << (day & 255);	
            }	
        }	
        return words;	
    }	
    	
    function _waasLobby(uint256 enterDay)	
        private	
        returns (uint256 waasLobby)	
    {
                /* 410958904109  = ~ 1500000 * SUNS_PER_DIV /365  */	
        if (enterDay > 0 && enterDay <= 365) {                                     	
            waasLobby = CLAIM_STARTING_AMOUNT - ((enterDay - 1) * 410958904109);
        } else {
            waasLobby = CLAIM_LOWEST_AMOUNT;
        }
        return waasLobby;
    }
    function _emitXfLobbyExit(
        uint256 enterDay,
        uint256 entryIndex,
        uint256 xfAmount,
        address referrerAddr
    )
        private
    {
        emit XfLobbyExit(
            block.timestamp, 
            enterDay,
            entryIndex,
            xfAmount,
            referrerAddr
        );
    }
} | 
	xfFlush | 
	function xfFlush()	
    external	
{	
    GlobalsCache memory g;	
    GlobalsCache memory gSnapshot;	
    _globalsLoad(g, gSnapshot);	
        	
    require(address(this).balance != 0, "CSNE: No value");	
    require(LAST_FLUSHED_DAY < _currentDay(), "CSNE: Invalid day");	
    _dailyDataUpdateAuto(g);	
    FLUSH_ADDR.transfer((dailyData[LAST_FLUSHED_DAY].dayDividends * 5) / 100);	
    LAST_FLUSHED_DAY++;	
    _globalsSync(g, gSnapshot);	
}	
 | 
	/**	
 * @dev PUBLIC FACING: Release 5% share from daily dividends for Website Maintenance and to add liquidity for Tokens in JustSwap Listing to support community	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    4146,
    4655
  ]
} | 4,620 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	TransformableToken | 
	contract TransformableToken is StakeableToken {	
    /**	
     * @dev PUBLIC FACING: Enter the auction lobby for the current round	
     * @param referrerAddr TRX address of referring user (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEnter(address referrerAddr)	
        external	
        payable	
    {	
	require(_currentDay() > 0, "CSNE: Auction has not begun yet");	
        uint256 enterDay = _currentDay();	
        uint256 rawAmount = msg.value;	
        require(rawAmount != 0, "CSNE: Amount required");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 entryIndex = qRef.tailIndex++;	
        qRef.entries[entryIndex] = XfLobbyEntryStore(uint96(rawAmount), referrerAddr);	
        xfLobby[enterDay] += rawAmount;	
        emit XfLobbyEnter(	
            block.timestamp, 	
            enterDay, 	
            entryIndex, 	
            rawAmount	
        );	
    }	
    /**	
     * @dev PUBLIC FACING: Leave the transform lobby after the round is complete	
     * @param enterDay Day number when the member entered	
     * @param count Number of queued-enters to exit (optional; 0 for all)	
     */	
    function xfLobbyExit(uint256 enterDay, uint256 count)	
        external	
    {	
        require(enterDay < _currentDay(), "CSNE: Round is not complete");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 headIndex = qRef.headIndex;	
        uint256 endIndex;	
        if (count != 0) {	
            require(count <= qRef.tailIndex - headIndex, "CSNE: count invalid");	
            endIndex = headIndex + count;	
        } else {	
            endIndex = qRef.tailIndex;	
            require(headIndex < endIndex, "CSNE: count invalid");	
        }	
        uint256 waasLobby = _waasLobby(enterDay);	
        uint256 _xfLobby = xfLobby[enterDay];	
        uint256 totalXfAmount = 0;	
        do {	
            uint256 rawAmount = qRef.entries[headIndex].rawAmount;	
            address referrerAddr = qRef.entries[headIndex].referrerAddr;	
            delete qRef.entries[headIndex];	
            uint256 xfAmount = waasLobby * rawAmount / _xfLobby;	
            if (referrerAddr == address(0) || referrerAddr == msg.sender) {	
                /* No referrer or Self-referred */	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
            } else {	
                /* Referral bonus of 5% of xfAmount to member */	
                uint256 referralBonusSuns = xfAmount / 20;	
                xfAmount += referralBonusSuns;	
                /* Then a cumulative referrer bonus of 10% to referrer */	
                uint256 referrerBonusSuns = xfAmount / 10;	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
                _mint(referrerAddr, referrerBonusSuns);	
            }	
            totalXfAmount += xfAmount;	
        } while (++headIndex < endIndex);	
        qRef.headIndex = uint40(headIndex);	
        if (totalXfAmount != 0) {	
            _mint(msg.sender, totalXfAmount);	
        }	
    }	
    /**	
     * @dev PUBLIC FACING: External helper to return multiple values of xfLobby[] with	
     * a single call	
     * @param beginDay First day of data range	
     * @param endDay Last day (non-inclusive) of data range	
     * @return Fixed array of values	
     */	
    function xfLobbyRange(uint256 beginDay, uint256 endDay)	
        external	
        view	
        returns (uint256[] memory list)	
    {	
        require(	
            beginDay < endDay && endDay <= _currentDay(),	
            "CSNE: invalid range"	
        );	
        list = new uint256[](endDay - beginDay);	
        uint256 src = beginDay;	
        uint256 dst = 0;	
        do {	
            list[dst++] = uint256(xfLobby[src++]);	
        } while (src < endDay);	
        return list;	
    }	
    /**	
     * @dev PUBLIC FACING: Release 5% share from daily dividends for Website Maintenance and to add liquidity for Tokens in JustSwap Listing to support community	
     */	
    function xfFlush()	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        	
        require(address(this).balance != 0, "CSNE: No value");	
        require(LAST_FLUSHED_DAY < _currentDay(), "CSNE: Invalid day");	
        _dailyDataUpdateAuto(g);	
        FLUSH_ADDR.transfer((dailyData[LAST_FLUSHED_DAY].dayDividends * 5) / 100);	
        LAST_FLUSHED_DAY++;	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return a current lobby member queue entry.	
     * Only needed due to limitations of the standard ABI encoder.	
     * @param entryIndex Entries to index	
     * @param enterDay Day number when the member entered	
     * @param memberAddr TRX address of the lobby member	
     * @return 1: Raw amount that was entered with; 2: Referring TRX addr (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEntry(address memberAddr, uint256 enterDay, uint256 entryIndex)	
        external	
        view	
        returns (uint256 rawAmount, address referrerAddr)	
    {	
        XfLobbyEntryStore storage entry = xfLobbyMembers[enterDay][memberAddr].entries[entryIndex];	
        require(entry.rawAmount != 0, "CSNE: Param invalid");	
        return (entry.rawAmount, entry.referrerAddr);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the lobby days that a user is in with a single call	
     * @param memberAddr TRX address of the user	
     * @return Bit vector of lobby day numbers	
     */	
    function xfLobbyPendingDays(address memberAddr)	
        external	
        view	
        returns (uint256[XF_LOBBY_DAY_WORDS] memory words)	
    {	
        uint256 day = _currentDay() + 1;	
        while (day-- != 0) {	
            if (xfLobbyMembers[day][memberAddr].tailIndex > xfLobbyMembers[day][memberAddr].headIndex) {	
                words[day >> 8] |= 1 << (day & 255);	
            }	
        }	
        return words;	
    }	
    	
    function _waasLobby(uint256 enterDay)	
        private	
        returns (uint256 waasLobby)	
    {
                /* 410958904109  = ~ 1500000 * SUNS_PER_DIV /365  */	
        if (enterDay > 0 && enterDay <= 365) {                                     	
            waasLobby = CLAIM_STARTING_AMOUNT - ((enterDay - 1) * 410958904109);
        } else {
            waasLobby = CLAIM_LOWEST_AMOUNT;
        }
        return waasLobby;
    }
    function _emitXfLobbyExit(
        uint256 enterDay,
        uint256 entryIndex,
        uint256 xfAmount,
        address referrerAddr
    )
        private
    {
        emit XfLobbyExit(
            block.timestamp, 
            enterDay,
            entryIndex,
            xfAmount,
            referrerAddr
        );
    }
} | 
	xfLobbyEntry | 
	function xfLobbyEntry(address memberAddr, uint256 enterDay, uint256 entryIndex)	
    external	
    view	
    returns (uint256 rawAmount, address referrerAddr)	
{	
    XfLobbyEntryStore storage entry = xfLobbyMembers[enterDay][memberAddr].entries[entryIndex];	
    require(entry.rawAmount != 0, "CSNE: Param invalid");	
    return (entry.rawAmount, entry.referrerAddr);	
}	
 | 
	/**	
 * @dev PUBLIC FACING: Return a current lobby member queue entry.	
 * Only needed due to limitations of the standard ABI encoder.	
 * @param entryIndex Entries to index	
 * @param enterDay Day number when the member entered	
 * @param memberAddr TRX address of the lobby member	
 * @return 1: Raw amount that was entered with; 2: Referring TRX addr (optional; 0x0 for no referrer)	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    5088,
    5505
  ]
} | 4,621 | ||
| 
	CSNE | 
	CSNE.sol | 
	0x7245b0fe11c4ae2978c8a8d29f3b74477ce6f789 | 
	Solidity | 
	TransformableToken | 
	contract TransformableToken is StakeableToken {	
    /**	
     * @dev PUBLIC FACING: Enter the auction lobby for the current round	
     * @param referrerAddr TRX address of referring user (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEnter(address referrerAddr)	
        external	
        payable	
    {	
	require(_currentDay() > 0, "CSNE: Auction has not begun yet");	
        uint256 enterDay = _currentDay();	
        uint256 rawAmount = msg.value;	
        require(rawAmount != 0, "CSNE: Amount required");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 entryIndex = qRef.tailIndex++;	
        qRef.entries[entryIndex] = XfLobbyEntryStore(uint96(rawAmount), referrerAddr);	
        xfLobby[enterDay] += rawAmount;	
        emit XfLobbyEnter(	
            block.timestamp, 	
            enterDay, 	
            entryIndex, 	
            rawAmount	
        );	
    }	
    /**	
     * @dev PUBLIC FACING: Leave the transform lobby after the round is complete	
     * @param enterDay Day number when the member entered	
     * @param count Number of queued-enters to exit (optional; 0 for all)	
     */	
    function xfLobbyExit(uint256 enterDay, uint256 count)	
        external	
    {	
        require(enterDay < _currentDay(), "CSNE: Round is not complete");	
        XfLobbyQueueStore storage qRef = xfLobbyMembers[enterDay][msg.sender];	
        uint256 headIndex = qRef.headIndex;	
        uint256 endIndex;	
        if (count != 0) {	
            require(count <= qRef.tailIndex - headIndex, "CSNE: count invalid");	
            endIndex = headIndex + count;	
        } else {	
            endIndex = qRef.tailIndex;	
            require(headIndex < endIndex, "CSNE: count invalid");	
        }	
        uint256 waasLobby = _waasLobby(enterDay);	
        uint256 _xfLobby = xfLobby[enterDay];	
        uint256 totalXfAmount = 0;	
        do {	
            uint256 rawAmount = qRef.entries[headIndex].rawAmount;	
            address referrerAddr = qRef.entries[headIndex].referrerAddr;	
            delete qRef.entries[headIndex];	
            uint256 xfAmount = waasLobby * rawAmount / _xfLobby;	
            if (referrerAddr == address(0) || referrerAddr == msg.sender) {	
                /* No referrer or Self-referred */	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
            } else {	
                /* Referral bonus of 5% of xfAmount to member */	
                uint256 referralBonusSuns = xfAmount / 20;	
                xfAmount += referralBonusSuns;	
                /* Then a cumulative referrer bonus of 10% to referrer */	
                uint256 referrerBonusSuns = xfAmount / 10;	
                _emitXfLobbyExit(enterDay, headIndex, xfAmount, referrerAddr);	
                _mint(referrerAddr, referrerBonusSuns);	
            }	
            totalXfAmount += xfAmount;	
        } while (++headIndex < endIndex);	
        qRef.headIndex = uint40(headIndex);	
        if (totalXfAmount != 0) {	
            _mint(msg.sender, totalXfAmount);	
        }	
    }	
    /**	
     * @dev PUBLIC FACING: External helper to return multiple values of xfLobby[] with	
     * a single call	
     * @param beginDay First day of data range	
     * @param endDay Last day (non-inclusive) of data range	
     * @return Fixed array of values	
     */	
    function xfLobbyRange(uint256 beginDay, uint256 endDay)	
        external	
        view	
        returns (uint256[] memory list)	
    {	
        require(	
            beginDay < endDay && endDay <= _currentDay(),	
            "CSNE: invalid range"	
        );	
        list = new uint256[](endDay - beginDay);	
        uint256 src = beginDay;	
        uint256 dst = 0;	
        do {	
            list[dst++] = uint256(xfLobby[src++]);	
        } while (src < endDay);	
        return list;	
    }	
    /**	
     * @dev PUBLIC FACING: Release 5% share from daily dividends for Website Maintenance and to add liquidity for Tokens in JustSwap Listing to support community	
     */	
    function xfFlush()	
        external	
    {	
        GlobalsCache memory g;	
        GlobalsCache memory gSnapshot;	
        _globalsLoad(g, gSnapshot);	
        	
        require(address(this).balance != 0, "CSNE: No value");	
        require(LAST_FLUSHED_DAY < _currentDay(), "CSNE: Invalid day");	
        _dailyDataUpdateAuto(g);	
        FLUSH_ADDR.transfer((dailyData[LAST_FLUSHED_DAY].dayDividends * 5) / 100);	
        LAST_FLUSHED_DAY++;	
        _globalsSync(g, gSnapshot);	
    }	
    /**	
     * @dev PUBLIC FACING: Return a current lobby member queue entry.	
     * Only needed due to limitations of the standard ABI encoder.	
     * @param entryIndex Entries to index	
     * @param enterDay Day number when the member entered	
     * @param memberAddr TRX address of the lobby member	
     * @return 1: Raw amount that was entered with; 2: Referring TRX addr (optional; 0x0 for no referrer)	
     */	
    function xfLobbyEntry(address memberAddr, uint256 enterDay, uint256 entryIndex)	
        external	
        view	
        returns (uint256 rawAmount, address referrerAddr)	
    {	
        XfLobbyEntryStore storage entry = xfLobbyMembers[enterDay][memberAddr].entries[entryIndex];	
        require(entry.rawAmount != 0, "CSNE: Param invalid");	
        return (entry.rawAmount, entry.referrerAddr);	
    }	
    /**	
     * @dev PUBLIC FACING: Return the lobby days that a user is in with a single call	
     * @param memberAddr TRX address of the user	
     * @return Bit vector of lobby day numbers	
     */	
    function xfLobbyPendingDays(address memberAddr)	
        external	
        view	
        returns (uint256[XF_LOBBY_DAY_WORDS] memory words)	
    {	
        uint256 day = _currentDay() + 1;	
        while (day-- != 0) {	
            if (xfLobbyMembers[day][memberAddr].tailIndex > xfLobbyMembers[day][memberAddr].headIndex) {	
                words[day >> 8] |= 1 << (day & 255);	
            }	
        }	
        return words;	
    }	
    	
    function _waasLobby(uint256 enterDay)	
        private	
        returns (uint256 waasLobby)	
    {
                /* 410958904109  = ~ 1500000 * SUNS_PER_DIV /365  */	
        if (enterDay > 0 && enterDay <= 365) {                                     	
            waasLobby = CLAIM_STARTING_AMOUNT - ((enterDay - 1) * 410958904109);
        } else {
            waasLobby = CLAIM_LOWEST_AMOUNT;
        }
        return waasLobby;
    }
    function _emitXfLobbyExit(
        uint256 enterDay,
        uint256 entryIndex,
        uint256 xfAmount,
        address referrerAddr
    )
        private
    {
        emit XfLobbyExit(
            block.timestamp, 
            enterDay,
            entryIndex,
            xfAmount,
            referrerAddr
        );
    }
} | 
	xfLobbyPendingDays | 
	function xfLobbyPendingDays(address memberAddr)	
    external	
    view	
    returns (uint256[XF_LOBBY_DAY_WORDS] memory words)	
{	
    uint256 day = _currentDay() + 1;	
    while (day-- != 0) {	
        if (xfLobbyMembers[day][memberAddr].tailIndex > xfLobbyMembers[day][memberAddr].headIndex) {	
            words[day >> 8] |= 1 << (day & 255);	
        }	
    }	
    return words;	
}	
 | 
	/**	
 * @dev PUBLIC FACING: Return the lobby days that a user is in with a single call	
 * @param memberAddr TRX address of the user	
 * @return Bit vector of lobby day numbers	
 */ | 
	NatSpecMultiLine | 
	v0.5.10+commit.5a6ea5b1 | 
	None | 
	bzzr://15b15fb6928768143d29c849842195f59d6c58b81754cc547f6ae35aeec04bef | 
	{
  "func_code_index": [
    5714,
    6166
  ]
} | 4,622 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	formatDecimals | 
	function formatDecimals(uint256 _value) internal returns (uint256 ) {
    return _value * 10 ** decimals;
}
 | 
	// 转换 | 
	LineComment | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    1143,
    1265
  ]
} | 4,623 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	GENEToken | 
	function GENEToken(
    address _ethFundDeposit,
    uint256 _currentSupply)
{
    ethFundDeposit = _ethFundDeposit;
 
    isFunding = false;                           //通过控制预CrowdS ale状态
    fundingStartBlock = 0;
    fundingStopBlock = 0;
 
    currentSupply = formatDecimals(_currentSupply);
    totalSupply = formatDecimals(1000000000);
    balances[msg.sender] = totalSupply;
    if(currentSupply > totalSupply) throw;
}
 | 
	// constructor | 
	LineComment | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    1289,
    1781
  ]
} | 4,624 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	setTokenExchangeRate | 
	function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
    if (_tokenExchangeRate == 0) throw;
    if (_tokenExchangeRate == tokenExchangeRate) throw;
 
    tokenExchangeRate = _tokenExchangeRate;
}
 | 
	///  设置token汇率 | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    1879,
    2125
  ]
} | 4,625 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	increaseSupply | 
	function increaseSupply (uint256 _value) isOwner external {
    uint256 value = formatDecimals(_value);
    if (value + currentSupply > totalSupply) throw;
    currentSupply = safeAdd(currentSupply, value);
    IncreaseSupply(value);
}
 | 
	/// @dev 超发token处理 | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    2153,
    2418
  ]
} | 4,626 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	decreaseSupply | 
	function decreaseSupply (uint256 _value) isOwner external {
    uint256 value = formatDecimals(_value);
    if (value + tokenRaised > currentSupply) throw;
 
    currentSupply = safeSubtract(currentSupply, value);
    DecreaseSupply(value);
}
 | 
	/// @dev 被盗token处理 | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    2446,
    2719
  ]
} | 4,627 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	startFunding | 
	function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
    if (isFunding) throw;
    if (_fundingStartBlock >= _fundingStopBlock) throw;
    if (block.number >= _fundingStartBlock) throw;
 
    fundingStartBlock = _fundingStartBlock;
    fundingStopBlock = _fundingStopBlock;
    isFunding = true;
}
 | 
	///  启动区块检测 异常的处理 | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    2746,
    3128
  ]
} | 4,628 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	stopFunding | 
	function stopFunding() isOwner external {
    if (!isFunding) throw;
    isFunding = false;
}
 | 
	///  关闭区块异常处理 | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    3151,
    3264
  ]
} | 4,629 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	setMigrateContract | 
	function setMigrateContract(address _newContractAddr) isOwner external {
    if (_newContractAddr == newContractAddr) throw;
    newContractAddr = _newContractAddr;
}
 | 
	/// 开发了一个新的合同来接收token(或者更新token) | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    3306,
    3492
  ]
} | 4,630 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	changeOwner | 
	function changeOwner(address _newFundDeposit) isOwner() external {
    if (_newFundDeposit == address(0x0)) throw;
    ethFundDeposit = _newFundDeposit;
}
 | 
	/// 设置新的所有者地址 | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    3515,
    3689
  ]
} | 4,631 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	migrate | 
	function migrate() external {
    if(isFunding) throw;
    if(newContractAddr == address(0x0)) throw;
 
    uint256 tokens = balances[msg.sender];
    if (tokens == 0) throw;
 
    balances[msg.sender] = 0;
    tokenMigrated = safeAdd(tokenMigrated, tokens);
 
    IMigrationContract newContract = IMigrationContract(newContractAddr);
    if (!newContract.migrate(msg.sender, tokens)) throw;
 
    Migrate(msg.sender, tokens);               // log it
}
 | 
	///转移token到新的合约 | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    3714,
    4225
  ]
} | 4,632 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	transferETH | 
	function transferETH() isOwner external {
    if (this.balance == 0) throw;
    if (!ethFundDeposit.send(this.balance)) throw;
}
 | 
	/// 转账ETH 到GENE团队 | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    4252,
    4400
  ]
} | 4,633 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	allocateToken | 
	function allocateToken (address _addr, uint256 _eth) isOwner external {
    if (_eth == 0) throw;
    if (_addr == address(0x0)) throw;
 
    uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
    if (tokens + tokenRaised > currentSupply) throw;
 
    tokenRaised = safeAdd(tokenRaised, tokens);
    balances[_addr] += tokens;
 
    AllocateToken(_addr, tokens);  // 记录token日志
}
 | 
	///  将GENE token分配到预处理地址。 | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    4435,
    4878
  ]
} | 4,634 | ||
| 
	GENEToken | 
	GENEToken.sol | 
	0xbb7c85dee0074a00bd0c13c85abe2ecbc7779914 | 
	Solidity | 
	GENEToken | 
	contract GENEToken is StandardToken, SafeMath {
 
    // metadata
    string  public constant name = "GENE";
    string  public constant symbol = "GE";
    uint256 public constant decimals = 18;
    string  public version = "1.0";
 
    // contracts
    address public ethFundDeposit;          // ETH存放地址
    address public newContractAddr;         // token更新地址
 
    // crowdsale parameters
    bool    public isFunding;                // 状态切换到true
    uint256 public fundingStartBlock;
    uint256 public fundingStopBlock;
 
    uint256 public currentSupply;           // 正在售卖中的tokens数量
    uint256 public tokenRaised = 0;         // 总的售卖数量token
    uint256 public tokenMigrated = 0;     // 总的已经交易的 token
    uint256 public tokenExchangeRate = 1;             // 0.0001 GE 兑换 1 ETH
 
    // events
    event AllocateToken(address indexed _to, uint256 _value);   // 分配的私有交易token;
    event IssueToken(address indexed _to, uint256 _value);      // 公开发行售卖的token;
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
 
    // 转换
    function formatDecimals(uint256 _value) internal returns (uint256 ) {
        return _value * 10 ** decimals;
    }
 
    // constructor
    function GENEToken(
        address _ethFundDeposit,
        uint256 _currentSupply)
    {
        ethFundDeposit = _ethFundDeposit;
 
        isFunding = false;                           //通过控制预CrowdS ale状态
        fundingStartBlock = 0;
        fundingStopBlock = 0;
 
        currentSupply = formatDecimals(_currentSupply);
        totalSupply = formatDecimals(1000000000);
        balances[msg.sender] = totalSupply;
        if(currentSupply > totalSupply) throw;
    }
 
    modifier isOwner()  { require(msg.sender == ethFundDeposit); _; }
 
    ///  设置token汇率
    function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external {
        if (_tokenExchangeRate == 0) throw;
        if (_tokenExchangeRate == tokenExchangeRate) throw;
 
        tokenExchangeRate = _tokenExchangeRate;
    }
 
    /// @dev 超发token处理
    function increaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + currentSupply > totalSupply) throw;
        currentSupply = safeAdd(currentSupply, value);
        IncreaseSupply(value);
    }
 
    /// @dev 被盗token处理
    function decreaseSupply (uint256 _value) isOwner external {
        uint256 value = formatDecimals(_value);
        if (value + tokenRaised > currentSupply) throw;
 
        currentSupply = safeSubtract(currentSupply, value);
        DecreaseSupply(value);
    }
 
    ///  启动区块检测 异常的处理
    function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
        if (isFunding) throw;
        if (_fundingStartBlock >= _fundingStopBlock) throw;
        if (block.number >= _fundingStartBlock) throw;
 
        fundingStartBlock = _fundingStartBlock;
        fundingStopBlock = _fundingStopBlock;
        isFunding = true;
    }
 
    ///  关闭区块异常处理
    function stopFunding() isOwner external {
        if (!isFunding) throw;
        isFunding = false;
    }
 
    /// 开发了一个新的合同来接收token(或者更新token)
    function setMigrateContract(address _newContractAddr) isOwner external {
        if (_newContractAddr == newContractAddr) throw;
        newContractAddr = _newContractAddr;
    }
 
    /// 设置新的所有者地址
    function changeOwner(address _newFundDeposit) isOwner() external {
        if (_newFundDeposit == address(0x0)) throw;
        ethFundDeposit = _newFundDeposit;
    }
 
    ///转移token到新的合约
    function migrate() external {
        if(isFunding) throw;
        if(newContractAddr == address(0x0)) throw;
 
        uint256 tokens = balances[msg.sender];
        if (tokens == 0) throw;
 
        balances[msg.sender] = 0;
        tokenMigrated = safeAdd(tokenMigrated, tokens);
 
        IMigrationContract newContract = IMigrationContract(newContractAddr);
        if (!newContract.migrate(msg.sender, tokens)) throw;
 
        Migrate(msg.sender, tokens);               // log it
    }
 
    /// 转账ETH 到GENE团队
    function transferETH() isOwner external {
        if (this.balance == 0) throw;
        if (!ethFundDeposit.send(this.balance)) throw;
    }
 
    ///  将GENE token分配到预处理地址。
    function allocateToken (address _addr, uint256 _eth) isOwner external {
        if (_eth == 0) throw;
        if (_addr == address(0x0)) throw;
 
        uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[_addr] += tokens;
 
        AllocateToken(_addr, tokens);  // 记录token日志
    }
 
    /// 购买token
    function () payable {
        if (!isFunding) throw;
        if (msg.value == 0) throw;
 
        if (block.number < fundingStartBlock) throw;
        if (block.number > fundingStopBlock) throw;
 
        uint256 tokens = safeMult(msg.value, tokenExchangeRate);
        if (tokens + tokenRaised > currentSupply) throw;
 
        tokenRaised = safeAdd(tokenRaised, tokens);
        balances[msg.sender] += tokens;
 
        IssueToken(msg.sender, tokens);  //记录日志
    }
} | 
	function () payable {
    if (!isFunding) throw;
    if (msg.value == 0) throw;
 
    if (block.number < fundingStartBlock) throw;
    if (block.number > fundingStopBlock) throw;
 
    uint256 tokens = safeMult(msg.value, tokenExchangeRate);
    if (tokens + tokenRaised > currentSupply) throw;
 
    tokenRaised = safeAdd(tokenRaised, tokens);
    balances[msg.sender] += tokens;
 
    IssueToken(msg.sender, tokens);  //记录日志
}
 | 
	/// 购买token | 
	NatSpecSingleLine | 
	v0.4.21+commit.dfe3193c | 
	None | 
	bzzr://4a571c11eb8bd6ba87335de5fc47943ed94ef9e2a4fa15d54f86ee351bd31848 | 
	{
  "func_code_index": [
    4899,
    5386
  ]
} | 4,635 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	function() noReentrancy payable{
  require(msg.value != 0);                        // Throw if value is 0
  require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
  bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
  if (crowdsaleState == state.priorityPass){
    if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
      processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
    }else{
      refundTransaction(stateChanged);            // Set state and return funds or throw
    }
  }
  else if(crowdsaleState == state.openedPriorityPass){
    if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
      processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
    }else{
      refundTransaction(stateChanged);            // Set state and return funds or throw
    }
  }
  else if(crowdsaleState == state.crowdsale){
    processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
  }
  else{
    refundTransaction(stateChanged);              // Set state and return funds or throw
  }
}
 | 
	//
// Unnamed function that runs when eth is sent to the contract
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    1503,
    2794
  ]
} | 4,636 | ||||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	checkCrowdsaleState | 
	function checkCrowdsaleState() internal returns (bool){
  if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
    crowdsaleState = state.crowdsaleEnded;
    MaxCapReached(block.number);                                                              // Close the crowdsale
    CrowdsaleEnded(block.number);                                                             // Raise event
    return true;
  }
  if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
    if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
      crowdsaleState = state.priorityPass;                                              // Set new state
      PresaleStarted(block.number);                                                     // Raise event
      return true;
    }
  }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
    if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
      crowdsaleState = state.openedPriorityPass;                                              // Set new state
      PresaleUnlimitedStarted(block.number);                                                  // Raise event
      return true;
    }
  }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
    if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
      crowdsaleState = state.crowdsale;                                                       // Set new state
      CrowdsaleStarted(block.number);                                                         // Raise event
      return true;
    }
  }else{
    if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
      crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
      CrowdsaleEnded(block.number);                                                           // Raise event
      return true;
    }
  }
  return false;
}
 | 
	//
// Check crowdsale state and calibrate it
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    2854,
    5337
  ]
} | 4,637 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	refundTransaction | 
	function refundTransaction(bool _stateChanged) internal{
  if (_stateChanged){
    msg.sender.transfer(msg.value);
  }else{
    revert();
  }
}
 | 
	//
// Decide if throw or only return ether
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    5395,
    5559
  ]
} | 4,638 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	calculateMaxContribution | 
	function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
  uint maxContrib;
  if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
    maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
    if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
      maxContrib = maxP1Cap - ethRaised;        // Alter max cap
    }
  }
  else{
    maxContrib = maxCap - ethRaised;            // Alter max cap
  }
  return maxContrib;
}
 | 
	//
// Calculate how much user can contribute
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    5619,
    6251
  ]
} | 4,639 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	processTransaction | 
	function processTransaction(address _contributor, uint _amount) internal{
  uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
  uint contributionAmount = _amount;
  uint returnAmount = 0;
  if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
    contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
    returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
  }
  if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
  if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
    contributorList[_contributor].isActive = true;                            // Set his activity to true
    contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
    contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
    nextContributorIndex++;
  }
  else{
    contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
  }
  ethRaised += contributionAmount;                                            // Add to eth raised
  uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
  if (tokenAmount > 0){
    token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
    contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
  }
  if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
}
 | 
	//
// Issue tokens and return if there is overflow
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    6317,
    8316
  ]
} | 4,640 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	editContributors | 
	function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
  require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
  for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
    if (contributorList[_contributorAddresses[cnt]].isActive){
      contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
    }
    else{
      contributorList[_contributorAddresses[cnt]].isActive = true;
      contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
      nextContributorIndex++;
    }
  }
}
 | 
	//
// Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    8439,
    9234
  ]
} | 4,641 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	salvageTokensFromContract | 
	function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
  IERC20Token(_tokenAddress).transfer(_to, _amount);
}
 | 
	//
// Method is needed for recovering tokens accedentaly sent to token address
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    9328,
    9487
  ]
} | 4,642 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	withdrawEth | 
	function withdrawEth() onlyOwner{
  require(this.balance != 0);
  require(ethRaised >= minCap);
  pendingEthWithdrawal = this.balance;
}
 | 
	//
// withdrawEth when minimum cap is reached
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    9548,
    9701
  ]
} | 4,643 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	claimEthIfFailed | 
	function claimEthIfFailed(){
  require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
  require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
  require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
  uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
  hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
  if (!msg.sender.send(ethContributed)){                                // Refund eth
    ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
  }
}
 | 
	//
// Users can claim their contribution if min cap is not raised
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    10015,
    10863
  ]
} | 4,644 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	batchReturnEthIfFailed | 
	function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
  require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
  address currentParticipantAddress;
  uint contribution;
  for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
    currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
    if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
    if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
      contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
      hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
      if (!currentParticipantAddress.send(contribution)){                           // Refund eth
        ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
      }
    }
    nextContributorToClaim += 1;                                                    // Repeat
  }
}
 | 
	//
// Owner can batch return contributors contributions(eth)
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    10939,
    12245
  ]
} | 4,645 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	withdrawRemainingBalanceForManualRecovery | 
	function withdrawRemainingBalanceForManualRecovery() onlyOwner{
  require(this.balance != 0);                                  // Check if there are any eth to claim
  require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
  require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
  multisigAddress.transfer(this.balance);                      // Withdraw to multisig
}
 | 
	//
// If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    12362,
    12830
  ]
} | 4,646 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	setMultisigAddress | 
	function setMultisigAddress(address _newAddress) onlyOwner{
  multisigAddress = _newAddress;
}
 | 
	//
// Owner can set multisig address for crowdsale
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    12896,
    12999
  ]
} | 4,647 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	setToken | 
	function setToken(address _newAddress) onlyOwner{
  token = IToken(_newAddress);
}
 | 
	//
// Owner can set token address where mints will happen
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    13072,
    13163
  ]
} | 4,648 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	claimCoreTeamsTokens | 
	function claimCoreTeamsTokens(address _to) onlyOwner{
  require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
  require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
  uint devReward = maxTokenSupply - token.totalSupply();
  if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
  token.mintTokens(_to, devReward);                             // Issue Teams tokens
  ownerHasClaimedTokens = true;                                 // Block further mints from this method
}
 | 
	//
// Owner can claim teams tokens when crowdsale has successfully ended
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    13251,
    13924
  ]
} | 4,649 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	claimCofounditTokens | 
	function claimCofounditTokens(){
  require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
  require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
  require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
  token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
  cofounditHasClaimedTokens = true;                   // Block further mints from this method
}
 | 
	//
// Cofoundit can claim their tokens
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    13978,
    14502
  ]
} | 4,650 | |||
| 
	DPPCrowdsale | 
	DPPCrowdsale.sol | 
	0x6f0d792b540afa2c8772b9ba4805e7436ad8413e | 
	Solidity | 
	Crowdsale | 
	contract Crowdsale is ReentrnacyHandlingContract, Owned{
  struct ContributorData{
    uint priorityPassAllowance;
    bool isActive;
    uint contributionAmount;
    uint tokensIssued;
  }
  mapping(address => ContributorData) public contributorList;
  uint nextContributorIndex;
  mapping(uint => address) contributorIndexes;
  state public crowdsaleState = state.pendingStart;
  enum state { pendingStart, priorityPass, openedPriorityPass, crowdsale, crowdsaleEnded }
  uint public presaleStartBlock;
  uint public presaleUnlimitedStartBlock;
  uint public crowdsaleStartBlock;
  uint public crowdsaleEndedBlock;
  event PresaleStarted(uint blockNumber);
  event PresaleUnlimitedStarted(uint blockNumber);
  event CrowdsaleStarted(uint blockNumber);
  event CrowdsaleEnded(uint blockNumber);
  event ErrorSendingETH(address to, uint amount);
  event MinCapReached(uint blockNumber);
  event MaxCapReached(uint blockNumber);
  IToken token = IToken(0x0);
  uint ethToTokenConversion;
  uint public minCap;
  uint public maxP1Cap;
  uint public maxCap;
  uint public ethRaised;
  address public multisigAddress;
  uint nextContributorToClaim;
  mapping(address => bool) hasClaimedEthWhenFail;
  uint maxTokenSupply;
  bool ownerHasClaimedTokens;
  uint cofounditReward;
  address cofounditAddress;
  address cofounditColdStorage;
  bool cofounditHasClaimedTokens;
  //
  // Unnamed function that runs when eth is sent to the contract
  //
  function() noReentrancy payable{
    require(msg.value != 0);                        // Throw if value is 0
    require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended
    bool stateChanged = checkCrowdsaleState();      // Check blocks and calibrate crowdsale state
    if (crowdsaleState == state.priorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.openedPriorityPass){
      if (contributorList[msg.sender].isActive){    // Check if contributor is in priorityPass
        processTransaction(msg.sender, msg.value);  // Process transaction and issue tokens
      }else{
        refundTransaction(stateChanged);            // Set state and return funds or throw
      }
    }
    else if(crowdsaleState == state.crowdsale){
      processTransaction(msg.sender, msg.value);    // Process transaction and issue tokens
    }
    else{
      refundTransaction(stateChanged);              // Set state and return funds or throw
    }
  }
  //
  // Check crowdsale state and calibrate it
  //
  function checkCrowdsaleState() internal returns (bool){
    if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded){                         // Check if max cap is reached
      crowdsaleState = state.crowdsaleEnded;
      MaxCapReached(block.number);                                                              // Close the crowdsale
      CrowdsaleEnded(block.number);                                                             // Raise event
      return true;
    }
    if (block.number > presaleStartBlock && block.number <= presaleUnlimitedStartBlock){  // Check if we are in presale phase
      if (crowdsaleState != state.priorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.priorityPass;                                              // Set new state
        PresaleStarted(block.number);                                                     // Raise event
        return true;
      }
    }else if(block.number > presaleUnlimitedStartBlock && block.number <= crowdsaleStartBlock){ // Check if we are in presale unlimited phase
      if (crowdsaleState != state.openedPriorityPass){                                          // Check if state needs to be changed
        crowdsaleState = state.openedPriorityPass;                                              // Set new state
        PresaleUnlimitedStarted(block.number);                                                  // Raise event
        return true;
      }
    }else if(block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock){        // Check if we are in crowdsale state
      if (crowdsaleState != state.crowdsale){                                                   // Check if state needs to be changed
        crowdsaleState = state.crowdsale;                                                       // Set new state
        CrowdsaleStarted(block.number);                                                         // Raise event
        return true;
      }
    }else{
      if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock){        // Check if crowdsale is over
        crowdsaleState = state.crowdsaleEnded;                                                  // Set new state
        CrowdsaleEnded(block.number);                                                           // Raise event
        return true;
      }
    }
    return false;
  }
  //
  // Decide if throw or only return ether
  //
  function refundTransaction(bool _stateChanged) internal{
    if (_stateChanged){
      msg.sender.transfer(msg.value);
    }else{
      revert();
    }
  }
  //
  // Calculate how much user can contribute
  //
  function calculateMaxContribution(address _contributor) constant returns (uint maxContribution){
    uint maxContrib;
    if (crowdsaleState == state.priorityPass){    // Check if we are in priority pass
      maxContrib = contributorList[_contributor].priorityPassAllowance - contributorList[_contributor].contributionAmount;
      if (maxContrib > (maxP1Cap - ethRaised)){   // Check if max contribution is more that max cap
        maxContrib = maxP1Cap - ethRaised;        // Alter max cap
      }
    }
    else{
      maxContrib = maxCap - ethRaised;            // Alter max cap
    }
    return maxContrib;
  }
  //
  // Issue tokens and return if there is overflow
  //
  function processTransaction(address _contributor, uint _amount) internal{
    uint maxContribution = calculateMaxContribution(_contributor);              // Calculate max users contribution
    uint contributionAmount = _amount;
    uint returnAmount = 0;
    if (maxContribution < _amount){                                             // Check if max contribution is lower than _amount sent
      contributionAmount = maxContribution;                                     // Set that user contibutes his maximum alowed contribution
      returnAmount = _amount - maxContribution;                                 // Calculate howmuch he must get back
    }
    if (ethRaised + contributionAmount > minCap && minCap > ethRaised) MinCapReached(block.number);
    if (contributorList[_contributor].isActive == false){                       // Check if contributor has already contributed
      contributorList[_contributor].isActive = true;                            // Set his activity to true
      contributorList[_contributor].contributionAmount = contributionAmount;    // Set his contribution
      contributorIndexes[nextContributorIndex] = _contributor;                  // Set contributors index
      nextContributorIndex++;
    }
    else{
      contributorList[_contributor].contributionAmount += contributionAmount;   // Add contribution amount to existing contributor
    }
    ethRaised += contributionAmount;                                            // Add to eth raised
    uint tokenAmount = contributionAmount * ethToTokenConversion;               // Calculate how much tokens must contributor get
    if (tokenAmount > 0){
      token.mintTokens(_contributor, tokenAmount);                                // Issue new tokens
      contributorList[_contributor].tokensIssued += tokenAmount;                  // log token issuance
    }
    if (returnAmount != 0) _contributor.transfer(returnAmount);                 // Return overflow of ether
  }
  //
  // Push contributor data to the contract before the crowdsale so that they are eligible for priorit pass
  //
  function editContributors(address[] _contributorAddresses, uint[] _contributorPPAllowances) onlyOwner{
    require(_contributorAddresses.length == _contributorPPAllowances.length); // Check if input data is correct
    for(uint cnt = 0; cnt < _contributorAddresses.length; cnt++){
      if (contributorList[_contributorAddresses[cnt]].isActive){
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
      }
      else{
        contributorList[_contributorAddresses[cnt]].isActive = true;
        contributorList[_contributorAddresses[cnt]].priorityPassAllowance = _contributorPPAllowances[cnt];
        contributorIndexes[nextContributorIndex] = _contributorAddresses[cnt];
        nextContributorIndex++;
      }
    }
  }
  //
  // Method is needed for recovering tokens accedentaly sent to token address
  //
  function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner{
    IERC20Token(_tokenAddress).transfer(_to, _amount);
  }
  //
  // withdrawEth when minimum cap is reached
  //
  function withdrawEth() onlyOwner{
    require(this.balance != 0);
    require(ethRaised >= minCap);
    pendingEthWithdrawal = this.balance;
  }
  uint pendingEthWithdrawal;
  function pullBalance(){
    require(msg.sender == multisigAddress);
    require(pendingEthWithdrawal > 0);
    multisigAddress.transfer(pendingEthWithdrawal);
    pendingEthWithdrawal = 0;
  }
  //
  // Users can claim their contribution if min cap is not raised
  //
  function claimEthIfFailed(){
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);    // Check if crowdsale has failed
    require(contributorList[msg.sender].contributionAmount > 0);          // Check if contributor has contributed to crowdsaleEndedBlock
    require(!hasClaimedEthWhenFail[msg.sender]);                          // Check if contributor has already claimed his eth
    uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution
    hasClaimedEthWhenFail[msg.sender] = true;                             // Set that he has claimed
    if (!msg.sender.send(ethContributed)){                                // Refund eth
      ErrorSendingETH(msg.sender, ethContributed);                        // If there is an issue raise event for manual recovery
    }
  }
  //
  // Owner can batch return contributors contributions(eth)
  //
  function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner{
    require(block.number > crowdsaleEndedBlock && ethRaised < minCap);                // Check if crowdsale has failed
    address currentParticipantAddress;
    uint contribution;
    for (uint cnt = 0; cnt < _numberOfReturns; cnt++){
      currentParticipantAddress = contributorIndexes[nextContributorToClaim];         // Get next unclaimed participant
      if (currentParticipantAddress == 0x0) return;                                   // Check if all the participants were compensated
      if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                        // Check if participant has already claimed
        contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant
        hasClaimedEthWhenFail[currentParticipantAddress] = true;                      // Set that he has claimed
        if (!currentParticipantAddress.send(contribution)){                           // Refund eth
          ErrorSendingETH(currentParticipantAddress, contribution);                   // If there is an issue raise event for manual recovery
        }
      }
      nextContributorToClaim += 1;                                                    // Repeat
    }
  }
  //
  // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery
  //
  function withdrawRemainingBalanceForManualRecovery() onlyOwner{
    require(this.balance != 0);                                  // Check if there are any eth to claim
    require(block.number > crowdsaleEndedBlock);                 // Check if crowdsale is over
    require(contributorIndexes[nextContributorToClaim] == 0x0);  // Check if all the users were refunded
    multisigAddress.transfer(this.balance);                      // Withdraw to multisig
  }
  //
  // Owner can set multisig address for crowdsale
  //
  function setMultisigAddress(address _newAddress) onlyOwner{
    multisigAddress = _newAddress;
  }
  //
  // Owner can set token address where mints will happen
  //
  function setToken(address _newAddress) onlyOwner{
    token = IToken(_newAddress);
  }
  //
  // Owner can claim teams tokens when crowdsale has successfully ended
  //
  function claimCoreTeamsTokens(address _to) onlyOwner{
    require(crowdsaleState == state.crowdsaleEnded);              // Check if crowdsale has ended
    require(!ownerHasClaimedTokens);                              // Check if owner has allready claimed tokens
    uint devReward = maxTokenSupply - token.totalSupply();
    if (!cofounditHasClaimedTokens) devReward -= cofounditReward; // If cofoundit has claimed tokens its ok if not set aside cofounditReward
    token.mintTokens(_to, devReward);                             // Issue Teams tokens
    ownerHasClaimedTokens = true;                                 // Block further mints from this method
  }
  //
  // Cofoundit can claim their tokens
  //
  function claimCofounditTokens(){
    require(msg.sender == cofounditAddress);            // Check if sender is cofoundit
    require(crowdsaleState == state.crowdsaleEnded);    // Check if crowdsale has ended
    require(!cofounditHasClaimedTokens);                // Check if cofoundit has allready claimed tokens
    token.mintTokens(cofounditColdStorage, cofounditReward);             // Issue cofoundit tokens
    cofounditHasClaimedTokens = true;                   // Block further mints from this method
  }
  function getTokenAddress() constant returns(address){
    return address(token);
  }
  //
  //  Before crowdsale starts owner can calibrate blocks of crowdsale stages
  //
  function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
    require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
    require(_presaleStartBlock != 0);                             // Check if any value is 0
    require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
    require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
    require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
    require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
    require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
    require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
    presaleStartBlock = _presaleStartBlock;
    presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
    crowdsaleStartBlock = _crowdsaleStartBlock;
    crowdsaleEndedBlock = _crowdsaleEndedBlock;
  }
} | 
	setCrowdsaleBlocks | 
	function setCrowdsaleBlocks(uint _presaleStartBlock, uint _presaleUnlimitedStartBlock, uint _crowdsaleStartBlock, uint _crowdsaleEndedBlock) onlyOwner{
  require(crowdsaleState == state.pendingStart);                // Check if crowdsale has started
  require(_presaleStartBlock != 0);                             // Check if any value is 0
  require(_presaleStartBlock < _presaleUnlimitedStartBlock);    // Check if presaleUnlimitedStartBlock is set properly
  require(_presaleUnlimitedStartBlock != 0);                    // Check if any value is 0
  require(_presaleUnlimitedStartBlock < _crowdsaleStartBlock);  // Check if crowdsaleStartBlock is set properly
  require(_crowdsaleStartBlock != 0);                           // Check if any value is 0
  require(_crowdsaleStartBlock < _crowdsaleEndedBlock);         // Check if crowdsaleEndedBlock is set properly
  require(_crowdsaleEndedBlock != 0);                           // Check if any value is 0
  presaleStartBlock = _presaleStartBlock;
  presaleUnlimitedStartBlock = _presaleUnlimitedStartBlock;
  crowdsaleStartBlock = _crowdsaleStartBlock;
  crowdsaleEndedBlock = _crowdsaleEndedBlock;
}
 | 
	//
//  Before crowdsale starts owner can calibrate blocks of crowdsale stages
// | 
	LineComment | 
	v0.4.16+commit.d7661dd9 | 
	bzzr://ff2415ea20052542e44eecc0b9e20c01f2afed4b77fb89f3252b0fa9c88ab9ec | 
	{
  "func_code_index": [
    14687,
    15881
  ]
} | 4,651 | |||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	Context | 
	contract Context {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.
    constructor () internal { }
    // solhint-disable-previous-line no-empty-blocks
    function _msgSender() internal view returns (address payable) {
        return msg.sender;
    }
    function _msgData() internal view returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
} | 
	_msgSender | 
	function _msgSender() internal view returns (address payable) {
    return msg.sender;
}
 | 
	// solhint-disable-previous-line no-empty-blocks | 
	LineComment | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    265,
    368
  ]
} | 4,652 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	Ownable | 
	contract Ownable is Context {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }
    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }
    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
} | 
	owner | 
	function owner() public view returns (address) {
    return _owner;
}
 | 
	/**
 * @dev Returns the address of the current owner.
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    497,
    581
  ]
} | 4,653 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	Ownable | 
	contract Ownable is Context {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }
    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }
    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
} | 
	isOwner | 
	function isOwner() public view returns (bool) {
    return _msgSender() == _owner;
}
 | 
	/**
 * @dev Returns true if the caller is the current owner.
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    863,
    962
  ]
} | 4,654 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	Ownable | 
	contract Ownable is Context {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }
    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }
    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
} | 
	renounceOwnership | 
	function renounceOwnership() public onlyOwner {
    emit OwnershipTransferred(_owner, address(0));
    _owner = address(0);
}
 | 
	/**
 * @dev Leaves the contract without owner. It will not be possible to call
 * `onlyOwner` functions anymore. Can only be called by the current owner.
 *
 * NOTE: Renouncing ownership will leave the contract without an owner,
 * thereby removing any functionality that is only available to the owner.
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    1308,
    1453
  ]
} | 4,655 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	Ownable | 
	contract Ownable is Context {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }
    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }
    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
} | 
	transferOwnership | 
	function transferOwnership(address newOwner) public onlyOwner {
    _transferOwnership(newOwner);
}
 | 
	/**
 * @dev Transfers ownership of the contract to a new account (`newOwner`).
 * Can only be called by the current owner.
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    1603,
    1717
  ]
} | 4,656 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	Ownable | 
	contract Ownable is Context {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }
    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }
    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
} | 
	_transferOwnership | 
	function _transferOwnership(address newOwner) internal {
    require(newOwner != address(0), "Ownable: new owner is the zero address");
    emit OwnershipTransferred(_owner, newOwner);
    _owner = newOwner;
}
 | 
	/**
 * @dev Transfers ownership of the contract to a new account (`newOwner`).
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    1818,
    2052
  ]
} | 4,657 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	add | 
	function add(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a + b;
    require(c >= a, "SafeMath: addition overflow");
    return c;
}
 | 
	/**
 * @dev Returns the addition of two unsigned integers, reverting on
 * overflow.
 *
 * Counterpart to Solidity's `+` operator.
 *
 * Requirements:
 * - Addition cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    251,
    437
  ]
} | 4,658 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	sub | 
	function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    return sub(a, b, "SafeMath: subtraction overflow");
}
 | 
	/**
 * @dev Returns the subtraction of two unsigned integers, reverting on
 * overflow (when the result is negative).
 *
 * Counterpart to Solidity's `-` operator.
 *
 * Requirements:
 * - Subtraction cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    707,
    848
  ]
} | 4,659 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	sub | 
	function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    require(b <= a, errorMessage);
    uint256 c = a - b;
    return c;
}
 | 
	/**
 * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
 * overflow (when the result is negative).
 *
 * Counterpart to Solidity's `-` operator.
 *
 * Requirements:
 * - Subtraction cannot overflow.
 *
 * _Available since v2.4.0._
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    1180,
    1377
  ]
} | 4,660 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	mul | 
	function mul(uint256 a, uint256 b) internal pure returns (uint256) {
    // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
    // benefit is lost if 'b' is also tested.
    // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
    if (a == 0) {
        return 0;
    }
    uint256 c = a * b;
    require(c / a == b, "SafeMath: multiplication overflow");
    return c;
}
 | 
	/**
 * @dev Returns the multiplication of two unsigned integers, reverting on
 * overflow.
 *
 * Counterpart to Solidity's `*` operator.
 *
 * Requirements:
 * - Multiplication cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    1623,
    2099
  ]
} | 4,661 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	div | 
	function div(uint256 a, uint256 b) internal pure returns (uint256) {
    return div(a, b, "SafeMath: division by zero");
}
 | 
	/**
 * @dev Returns the integer division of two unsigned integers. Reverts on
 * division by zero. The result is rounded towards zero.
 *
 * Counterpart to Solidity's `/` operator. Note: this function uses a
 * `revert` opcode (which leaves remaining gas untouched) while Solidity
 * uses an invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 * - The divisor cannot be zero.
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    2562,
    2699
  ]
} | 4,662 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	div | 
	function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    // Solidity only automatically asserts when dividing by 0
    require(b > 0, errorMessage);
    uint256 c = a / b;
    // assert(a == b * c + a % b); // There is no case in which this doesn't hold
    return c;
}
 | 
	/**
 * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
 * division by zero. The result is rounded towards zero.
 *
 * Counterpart to Solidity's `/` operator. Note: this function uses a
 * `revert` opcode (which leaves remaining gas untouched) while Solidity
 * uses an invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 * - The divisor cannot be zero.
 *
 * _Available since v2.4.0._
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    3224,
    3574
  ]
} | 4,663 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	mod | 
	function mod(uint256 a, uint256 b) internal pure returns (uint256) {
    return mod(a, b, "SafeMath: modulo by zero");
}
 | 
	/**
 * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
 * Reverts when dividing by zero.
 *
 * Counterpart to Solidity's `%` operator. This function uses a `revert`
 * opcode (which leaves remaining gas untouched) while Solidity uses an
 * invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 * - The divisor cannot be zero.
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    4026,
    4161
  ]
} | 4,664 | ||
| 
	MythicalDice | 
	MythicalDice.sol | 
	0xb68a6191ccbc0e4bf74af1635aa7b2ab7c09f0df | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	mod | 
	function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    require(b != 0, errorMessage);
    return a % b;
}
 | 
	/**
 * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
 * Reverts with custom message when dividing by zero.
 *
 * Counterpart to Solidity's `%` operator. This function uses a `revert`
 * opcode (which leaves remaining gas untouched) while Solidity uses an
 * invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 * - The divisor cannot be zero.
 *
 * _Available since v2.4.0._
 */ | 
	NatSpecMultiLine | 
	v0.5.16+commit.9c3226ce | 
	None | 
	bzzr://e650842e5c31d62e03cf0e61f20d86de70486b27cce654e1d44687a78bcd3a23 | 
	{
  "func_code_index": [
    4675,
    4846
  ]
} | 4,665 | ||
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	balanceOf | 
	function balanceOf(address account) external view returns (uint256);
 | 
	/**
 * @dev Returns the amount of tokens owned by `account`.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    165,
    238
  ]
} | 4,666 | ||
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	transfer | 
	function transfer(address recipient, uint256 amount) external returns (bool);
 | 
	/**
 * @dev Moves `amount` tokens from the caller's account to `recipient`.
 *
 * Returns a boolean value indicating whether the operation succeeded.
 *
 * Emits a {Transfer} event.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    462,
    544
  ]
} | 4,667 | ||
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	allowance | 
	function allowance(address owner, address spender) external view returns (uint256);
 | 
	/**
 * @dev Returns the remaining number of tokens that `spender` will be
 * allowed to spend on behalf of `owner` through {transferFrom}. This is
 * zero by default.
 *
 * This value changes when {approve} or {transferFrom} are called.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    823,
    911
  ]
} | 4,668 | ||
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	approve | 
	function approve(address spender, uint256 amount) external returns (bool);
 | 
	/**
 * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
 *
 * Returns a boolean value indicating whether the operation succeeded.
 *
 * IMPORTANT: Beware that changing an allowance with this method brings the risk
 * that someone may use both the old and the new allowance by unfortunate
 * transaction ordering. One possible solution to mitigate this race
 * condition is to first reduce the spender's allowance to 0 and set the
 * desired value afterwards:
 * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
 *
 * Emits an {Approval} event.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    1575,
    1654
  ]
} | 4,669 | ||
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	transferFrom | 
	function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
 | 
	/**
 * @dev Moves `amount` tokens from `sender` to `recipient` using the
 * allowance mechanism. `amount` is then deducted from the caller's
 * allowance.
 *
 * Returns a boolean value indicating whether the operation succeeded.
 *
 * Emits a {Transfer} event.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    1967,
    2069
  ]
} | 4,670 | ||
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	add | 
	function add(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a + b;
    require(c >= a, "SafeMath: addition overflow");
    return c;
}
 | 
	/**
 * @dev Returns the addition of two unsigned integers, reverting on
 * overflow.
 *
 * Counterpart to Solidity's `+` operator.
 *
 * Requirements:
 *
 * - Addition cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    259,
    445
  ]
} | 4,671 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	sub | 
	function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    return sub(a, b, "SafeMath: subtraction overflow");
}
 | 
	/**
 * @dev Returns the subtraction of two unsigned integers, reverting on
 * overflow (when the result is negative).
 *
 * Counterpart to Solidity's `-` operator.
 *
 * Requirements:
 *
 * - Subtraction cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    723,
    864
  ]
} | 4,672 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	sub | 
	function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    require(b <= a, errorMessage);
    uint256 c = a - b;
    return c;
}
 | 
	/**
 * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
 * overflow (when the result is negative).
 *
 * Counterpart to Solidity's `-` operator.
 *
 * Requirements:
 *
 * - Subtraction cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    1162,
    1359
  ]
} | 4,673 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	mul | 
	function mul(uint256 a, uint256 b) internal pure returns (uint256) {
    // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
    // benefit is lost if 'b' is also tested.
    // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
    if (a == 0) {
        return 0;
    }
    uint256 c = a * b;
    require(c / a == b, "SafeMath: multiplication overflow");
    return c;
}
 | 
	/**
 * @dev Returns the multiplication of two unsigned integers, reverting on
 * overflow.
 *
 * Counterpart to Solidity's `*` operator.
 *
 * Requirements:
 *
 * - Multiplication cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    1613,
    2089
  ]
} | 4,674 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	div | 
	function div(uint256 a, uint256 b) internal pure returns (uint256) {
    return div(a, b, "SafeMath: division by zero");
}
 | 
	/**
 * @dev Returns the integer division of two unsigned integers. Reverts on
 * division by zero. The result is rounded towards zero.
 *
 * Counterpart to Solidity's `/` operator. Note: this function uses a
 * `revert` opcode (which leaves remaining gas untouched) while Solidity
 * uses an invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 *
 * - The divisor cannot be zero.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    2560,
    2697
  ]
} | 4,675 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	div | 
	function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    require(b > 0, errorMessage);
    uint256 c = a / b;
    // assert(a == b * c + a % b); // There is no case in which this doesn't hold
    return c;
}
 | 
	/**
 * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
 * division by zero. The result is rounded towards zero.
 *
 * Counterpart to Solidity's `/` operator. Note: this function uses a
 * `revert` opcode (which leaves remaining gas untouched) while Solidity
 * uses an invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 *
 * - The divisor cannot be zero.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    3188,
    3471
  ]
} | 4,676 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	mod | 
	function mod(uint256 a, uint256 b) internal pure returns (uint256) {
    return mod(a, b, "SafeMath: modulo by zero");
}
 | 
	/**
 * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
 * Reverts when dividing by zero.
 *
 * Counterpart to Solidity's `%` operator. This function uses a `revert`
 * opcode (which leaves remaining gas untouched) while Solidity uses an
 * invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 *
 * - The divisor cannot be zero.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    3931,
    4066
  ]
} | 4,677 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	mod | 
	function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    require(b != 0, errorMessage);
    return a % b;
}
 | 
	/**
 * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
 * Reverts with custom message when dividing by zero.
 *
 * Counterpart to Solidity's `%` operator. This function uses a `revert`
 * opcode (which leaves remaining gas untouched) while Solidity uses an
 * invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 *
 * - The divisor cannot be zero.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    4546,
    4717
  ]
} | 4,678 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Address | 
	library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }
    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");
        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }
    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }
    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");
        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
} | 
	/**
 * @dev Collection of functions related to the address type
 */ | 
	NatSpecMultiLine | 
	isContract | 
	function isContract(address account) internal view returns (bool) {
    // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
    // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
    // for accounts without code, i.e. `keccak256('')`
    bytes32 codehash;
    bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
    // solhint-disable-next-line no-inline-assembly
    assembly { codehash := extcodehash(account) }
    return (codehash != accountHash && codehash != 0x0);
}
 | 
	/**
 * @dev Returns true if `account` is a contract.
 *
 * [IMPORTANT]
 * ====
 * It is unsafe to assume that an address for which this function returns
 * false is an externally-owned account (EOA) and not a contract.
 *
 * Among others, `isContract` will return false for the following
 * types of addresses:
 *
 *  - an externally-owned account
 *  - a contract in construction
 *  - an address where a contract will be created
 *  - an address where a contract lived, but was destroyed
 * ====
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    606,
    1230
  ]
} | 4,679 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Address | 
	library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }
    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");
        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }
    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }
    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");
        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
} | 
	/**
 * @dev Collection of functions related to the address type
 */ | 
	NatSpecMultiLine | 
	sendValue | 
	function sendValue(address payable recipient, uint256 amount) internal {
    require(address(this).balance >= amount, "Address: insufficient balance");
    // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
    (bool success, ) = recipient.call{ value: amount }("");
    require(success, "Address: unable to send value, recipient may have reverted");
}
 | 
	/**
 * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
 * `recipient`, forwarding all available gas and reverting on errors.
 *
 * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
 * of certain opcodes, possibly making contracts go over the 2300 gas limit
 * imposed by `transfer`, making them unable to receive funds via
 * `transfer`. {sendValue} removes this limitation.
 *
 * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
 *
 * IMPORTANT: because control is transferred to `recipient`, care must be
 * taken to not create reentrancy vulnerabilities. Consider using
 * {ReentrancyGuard} or the
 * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    2160,
    2562
  ]
} | 4,680 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Address | 
	library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }
    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");
        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }
    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }
    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");
        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
} | 
	/**
 * @dev Collection of functions related to the address type
 */ | 
	NatSpecMultiLine | 
	functionCall | 
	function functionCall(address target, bytes memory data) internal returns (bytes memory) {
  return functionCall(target, data, "Address: low-level call failed");
}
 | 
	/**
 * @dev Performs a Solidity function call using a low level `call`. A
 * plain`call` is an unsafe replacement for a function call: use this
 * function instead.
 *
 * If `target` reverts with a revert reason, it is bubbled up by this
 * function (like regular Solidity function calls).
 *
 * Returns the raw returned data. To convert to the expected return value,
 * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
 *
 * Requirements:
 *
 * - `target` must be a contract.
 * - calling `target` with `data` must not revert.
 *
 * _Available since v3.1._
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    3318,
    3496
  ]
} | 4,681 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Address | 
	library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }
    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");
        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }
    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }
    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");
        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
} | 
	/**
 * @dev Collection of functions related to the address type
 */ | 
	NatSpecMultiLine | 
	functionCall | 
	function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
    return _functionCallWithValue(target, data, 0, errorMessage);
}
 | 
	/**
 * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
 * `errorMessage` as a fallback revert reason when `target` reverts.
 *
 * _Available since v3.1._
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    3721,
    3922
  ]
} | 4,682 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Address | 
	library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }
    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");
        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }
    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }
    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");
        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
} | 
	/**
 * @dev Collection of functions related to the address type
 */ | 
	NatSpecMultiLine | 
	functionCallWithValue | 
	function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
    return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
 | 
	/**
 * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
 * but also transferring `value` wei to `target`.
 *
 * Requirements:
 *
 * - the calling contract must have an ETH balance of at least `value`.
 * - the called Solidity function must be `payable`.
 *
 * _Available since v3.1._
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    4292,
    4523
  ]
} | 4,683 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Address | 
	library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }
    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");
        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, errorMessage);
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }
    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        return _functionCallWithValue(target, data, value, errorMessage);
    }
    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");
        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
} | 
	/**
 * @dev Collection of functions related to the address type
 */ | 
	NatSpecMultiLine | 
	functionCallWithValue | 
	function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
    require(address(this).balance >= value, "Address: insufficient balance for call");
    return _functionCallWithValue(target, data, value, errorMessage);
}
 | 
	/**
 * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
 * with `errorMessage` as a fallback revert reason when `target` reverts.
 *
 * _Available since v3.1._
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    4774,
    5095
  ]
} | 4,684 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Ownable | 
	contract Ownable is Context {
    address private _owner;
    address private _previousOwner;
    uint256 private _lockTime;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }
     /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
    function geUnlockTime() public view returns (uint256) {
        return _lockTime;
    }
    //Locks the contract for owner for the amount of time provided
    function lock(uint256 time) public virtual onlyOwner {
        _previousOwner = _owner;
        _owner = address(0);
        _lockTime = now + time;
        emit OwnershipTransferred(_owner, address(0));
    }
    
    //Unlocks the contract for owner when _lockTime is exceeds
    function unlock() public virtual {
        require(_previousOwner == msg.sender, "You don't have permission to unlock");
        require(now > _lockTime , "Contract is locked until 7 days");
        emit OwnershipTransferred(_owner, _previousOwner);
        _owner = _previousOwner;
    }
} | 
	/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */ | 
	NatSpecMultiLine | 
	owner | 
	function owner() public view returns (address) {
    return _owner;
}
 | 
	/**
 * @dev Returns the address of the current owner.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    566,
    650
  ]
} | 4,685 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Ownable | 
	contract Ownable is Context {
    address private _owner;
    address private _previousOwner;
    uint256 private _lockTime;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }
     /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
    function geUnlockTime() public view returns (uint256) {
        return _lockTime;
    }
    //Locks the contract for owner for the amount of time provided
    function lock(uint256 time) public virtual onlyOwner {
        _previousOwner = _owner;
        _owner = address(0);
        _lockTime = now + time;
        emit OwnershipTransferred(_owner, address(0));
    }
    
    //Unlocks the contract for owner when _lockTime is exceeds
    function unlock() public virtual {
        require(_previousOwner == msg.sender, "You don't have permission to unlock");
        require(now > _lockTime , "Contract is locked until 7 days");
        emit OwnershipTransferred(_owner, _previousOwner);
        _owner = _previousOwner;
    }
} | 
	/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */ | 
	NatSpecMultiLine | 
	renounceOwnership | 
	function renounceOwnership() public virtual onlyOwner {
    emit OwnershipTransferred(_owner, address(0));
    _owner = address(0);
}
 | 
	/**
 * @dev Leaves the contract without owner. It will not be possible to call
 * `onlyOwner` functions anymore. Can only be called by the current owner.
 *
 * NOTE: Renouncing ownership will leave the contract without an owner,
 * thereby removing any functionality that is only available to the owner.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    1209,
    1362
  ]
} | 4,686 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Ownable | 
	contract Ownable is Context {
    address private _owner;
    address private _previousOwner;
    uint256 private _lockTime;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }
     /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
    function geUnlockTime() public view returns (uint256) {
        return _lockTime;
    }
    //Locks the contract for owner for the amount of time provided
    function lock(uint256 time) public virtual onlyOwner {
        _previousOwner = _owner;
        _owner = address(0);
        _lockTime = now + time;
        emit OwnershipTransferred(_owner, address(0));
    }
    
    //Unlocks the contract for owner when _lockTime is exceeds
    function unlock() public virtual {
        require(_previousOwner == msg.sender, "You don't have permission to unlock");
        require(now > _lockTime , "Contract is locked until 7 days");
        emit OwnershipTransferred(_owner, _previousOwner);
        _owner = _previousOwner;
    }
} | 
	/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */ | 
	NatSpecMultiLine | 
	transferOwnership | 
	function transferOwnership(address newOwner) public virtual onlyOwner {
    require(newOwner != address(0), "Ownable: new owner is the zero address");
    emit OwnershipTransferred(_owner, newOwner);
    _owner = newOwner;
}
 | 
	/**
 * @dev Transfers ownership of the contract to a new account (`newOwner`).
 * Can only be called by the current owner.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    1512,
    1761
  ]
} | 4,687 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Ownable | 
	contract Ownable is Context {
    address private _owner;
    address private _previousOwner;
    uint256 private _lockTime;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }
     /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
    function geUnlockTime() public view returns (uint256) {
        return _lockTime;
    }
    //Locks the contract for owner for the amount of time provided
    function lock(uint256 time) public virtual onlyOwner {
        _previousOwner = _owner;
        _owner = address(0);
        _lockTime = now + time;
        emit OwnershipTransferred(_owner, address(0));
    }
    
    //Unlocks the contract for owner when _lockTime is exceeds
    function unlock() public virtual {
        require(_previousOwner == msg.sender, "You don't have permission to unlock");
        require(now > _lockTime , "Contract is locked until 7 days");
        emit OwnershipTransferred(_owner, _previousOwner);
        _owner = _previousOwner;
    }
} | 
	/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */ | 
	NatSpecMultiLine | 
	lock | 
	function lock(uint256 time) public virtual onlyOwner {
    _previousOwner = _owner;
    _owner = address(0);
    _lockTime = now + time;
    emit OwnershipTransferred(_owner, address(0));
}
 | 
	//Locks the contract for owner for the amount of time provided | 
	LineComment | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    1929,
    2148
  ]
} | 4,688 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Ownable | 
	contract Ownable is Context {
    address private _owner;
    address private _previousOwner;
    uint256 private _lockTime;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }
    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }
    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }
     /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
    function geUnlockTime() public view returns (uint256) {
        return _lockTime;
    }
    //Locks the contract for owner for the amount of time provided
    function lock(uint256 time) public virtual onlyOwner {
        _previousOwner = _owner;
        _owner = address(0);
        _lockTime = now + time;
        emit OwnershipTransferred(_owner, address(0));
    }
    
    //Unlocks the contract for owner when _lockTime is exceeds
    function unlock() public virtual {
        require(_previousOwner == msg.sender, "You don't have permission to unlock");
        require(now > _lockTime , "Contract is locked until 7 days");
        emit OwnershipTransferred(_owner, _previousOwner);
        _owner = _previousOwner;
    }
} | 
	/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */ | 
	NatSpecMultiLine | 
	unlock | 
	function unlock() public virtual {
    require(_previousOwner == msg.sender, "You don't have permission to unlock");
    require(now > _lockTime , "Contract is locked until 7 days");
    emit OwnershipTransferred(_owner, _previousOwner);
    _owner = _previousOwner;
}
 | 
	//Unlocks the contract for owner when _lockTime is exceeds | 
	LineComment | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    2219,
    2517
  ]
} | 4,689 | 
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Fubuki | 
	contract Fubuki is Context, IERC20, Ownable {
    using SafeMath for uint256;
    using Address for address;
    mapping (address => uint256) private _rOwned;
    mapping (address => uint256) private _tOwned;
    mapping (address => mapping (address => uint256)) private _allowances;
    mapping (address => bool) private _isExcludedFromFee;
    mapping (address => bool) private _isExcludedFromMax;
    mapping (address => bool) private _isExcluded;
    mapping (address => bool) isBlacklisted;
    address[] private _excluded;
   
    uint256 private constant MAX = ~uint256(0);
    uint256 private _tTotal = 100000069 * 10**18;
    uint256 private _rTotal = (MAX - (MAX % _tTotal));
    uint256 private _tFeeTotal;
    address private _devAddress = 0xF3C38c8dD73557c03558d56CC1f36DcCB5BA01EC;
    address private _burnAddress = 0x0000000000000000000000000000000000000001;
    string private _name = "Fubuki Token";
    string private _symbol = "FUBUKI";
    uint8 private _decimals = 18;
    
    uint256 public _taxFee = 2;
    uint256 private _previousTaxFee = _taxFee;
    uint256 public _devFee = 5;
    uint256 private _previousDevFee = _devFee;
    uint256 public _burnFee = 2;
    uint256 private _previousBurnFee = _burnFee;
    uint256 private _beforeLaunchFee = 99;
    uint256 private _previousBeforeLaunchFee = _beforeLaunchFee;
    uint256 public launchedAt;
    uint256 public launchedAtTimestamp;
    IUniswapV2Router02 public immutable uniswapV2Router;
    address public uniswapV2Pair;
        
    uint256 public _maxTxAmount = _tTotal.div(200).mul(1);
    uint256 public _maxWalletToken = _tTotal.div(100).mul(1);
        
    constructor () public {
        _rOwned[_msgSender()] = _rTotal;
        
        IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
         // Create a uniswap pair for this new token
        uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
            .createPair(address(this), _uniswapV2Router.WETH());
        // set the rest of the contract variables
        uniswapV2Router = _uniswapV2Router;
        // exclude owner, dev wallet, and this contract from fee
        _isExcludedFromFee[owner()] = true;
        _isExcludedFromFee[address(this)] = true;
        _isExcludedFromFee[_devAddress] = true;
        _isExcludedFromMax[owner()] = true;
        _isExcludedFromMax[address(this)] = true;
        _isExcludedFromMax[_devAddress] = true;
        _isExcludedFromMax[uniswapV2Pair] = true;
        emit Transfer(address(0), _msgSender(), _tTotal);
    }
    function name() public view returns (string memory) {
        return _name;
    }
    function symbol() public view returns (string memory) {
        return _symbol;
    }
    function decimals() public view returns (uint8) {
        return _decimals;
    }
    function totalSupply() public view override returns (uint256) {
        return _tTotal;
    }
    function balanceOf(address account) public view override returns (uint256) {
        if (_isExcluded[account]) return _tOwned[account];
        return tokenFromReflection(_rOwned[account]);
    }
    function transfer(address recipient, uint256 amount) public override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }
    function allowance(address owner, address spender) public view override returns (uint256) {
        return _allowances[owner][spender];
    }
    function approve(address spender, uint256 amount) public override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }
    function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }
    function isExcludedFromReward(address account) public view returns (bool) {
        return _isExcluded[account];
    }
    function setIsBlacklisted(address account, bool blacklisted) external onlyOwner() {
        isBlacklisted[account] = blacklisted;
    }
    function blacklistMultipleAccounts(address[] calldata accounts, bool blacklisted) external onlyOwner() {
        for (uint256 i = 0; i < accounts.length; i++) {
            isBlacklisted[accounts[i]] = blacklisted;
        }
    }
    function isAccountBlacklisted(address account) external view returns (bool) {
        return isBlacklisted[account];
    }
    function isExcludedFromMax(address holder, bool exempt) external onlyOwner() {
        _isExcludedFromMax[holder] = exempt;
    }
    function totalFees() public view returns (uint256) {
        return _tFeeTotal;
    }
    function burnAddress() public view returns (address) {
        return _burnAddress;
    }
    function devAddress() public view returns (address) {
        return _devAddress;
    }
    function launch() public onlyOwner() {
        require(launchedAt == 0, "Already launched.");
        launchedAt = block.number;
        launchedAtTimestamp = block.timestamp;
    }
    function deliver(uint256 tAmount) public {
        address sender = _msgSender();
        require(!_isExcluded[sender], "Excluded addresses cannot call this function");
        (,uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount,,) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _rTotal = _rTotal.sub(rAmount);
        _tFeeTotal = _tFeeTotal.add(tAmount);
    }
    function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
        require(tAmount <= _tTotal, "Amount must be less than supply");
        
        (,uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount, uint256 rTransferAmount,) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        if (!deductTransferFee) {
            return rAmount;
        } else {
            return rTransferAmount;
        }
    }
    function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
        require(rAmount <= _rTotal, "Amount must be less than total reflections");
        uint256 currentRate =  _getRate();
        return rAmount.div(currentRate);
    }
    function excludeFromReward(address account) public onlyOwner() {
        require(!_isExcluded[account], "Account is already excluded");
        if(_rOwned[account] > 0) {
            _tOwned[account] = tokenFromReflection(_rOwned[account]);
        }
        _isExcluded[account] = true;
        _excluded.push(account);
    }
    function includeInReward(address account) external onlyOwner() {
        require(_isExcluded[account], "Account is not excluded");
        for (uint256 i = 0; i < _excluded.length; i++) {
            if (_excluded[i] == account) {
                _excluded[i] = _excluded[_excluded.length - 1];
                _tOwned[account] = 0;
                _isExcluded[account] = false;
                _excluded.pop();
                break;
            }
        }
    }
        
    function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
        (uint256 tTransferAmount, uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        _tOwned[sender] = _tOwned[sender].sub(tAmount);
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
        _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
        _takeDevFee(tDev);
        _takeBurnFee(tBurn);
        _reflectFee(rFee, tFee);
        emit Transfer(sender, recipient, tTransferAmount);
    }
        
    function excludeFromFee(address account) public onlyOwner {
        _isExcludedFromFee[account] = true;
    }
    
    function includeInFee(address account) public onlyOwner {
        _isExcludedFromFee[account] = false;
    }
    
    function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
        _taxFee = taxFee;
    }
    
    function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
        _maxTxAmount = _tTotal.mul(maxTxPercent).div(
            10**2
        );
    }
    function setMaxWalletPercent(uint256 maxWalletToken) external onlyOwner() {
        _maxWalletToken = _tTotal.mul(maxWalletToken).div(
            10**2
        );
    }
    
     //to recieve ETH from uniswapV2Router when swapping
    receive() external payable {}
    function _reflectFee(uint256 rFee, uint256 tFee) private {
        _rTotal = _rTotal.sub(rFee);
        _tFeeTotal = _tFeeTotal.add(tFee);
    }
    function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) {
        uint256 tFee = calculateTaxFee(tAmount);
        uint256 tDev = calculateDevFee(tAmount);
        uint256 tBurn = calculateBurnFee(tAmount);
        uint256 tTransferAmount = tAmount.sub(tFee).sub(tDev);
                tTransferAmount = tTransferAmount.sub(tBurn);
        return (tTransferAmount, tFee, tDev, tBurn);
    }
    function _getRValues(uint256 tAmount, uint256 tFee, uint256 tDev, uint256 tBurn, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
        uint256 rAmount = tAmount.mul(currentRate);
        uint256 rFee = tFee.mul(currentRate);
        uint256 rDev = tDev.mul(currentRate);
        uint256 rBurn = tBurn.mul(currentRate);
        uint256 rTransferAmount = rAmount.sub(rFee).sub(rDev).sub(rBurn);
        return (rAmount, rTransferAmount, rFee);
    }
    function _getRate() private view returns(uint256) {
        (uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
        return rSupply.div(tSupply);
    }
    function _getCurrentSupply() private view returns(uint256, uint256) {
        uint256 rSupply = _rTotal;
        uint256 tSupply = _tTotal;      
        for (uint256 i = 0; i < _excluded.length; i++) {
            if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
            rSupply = rSupply.sub(_rOwned[_excluded[i]]);
            tSupply = tSupply.sub(_tOwned[_excluded[i]]);
        }
        if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
        return (rSupply, tSupply);
    }
    function _takeDevFee(uint256 tDev) private {
        uint256 currentRate =  _getRate();
        uint256 rDev = tDev.mul(currentRate);
        _rOwned[_devAddress] = _rOwned[_devAddress].add(rDev);
        if(_isExcluded[_devAddress])
            _tOwned[_devAddress] = _tOwned[_devAddress].add(tDev);
    }
    function _takeBurnFee(uint256 tBurn) private {
        uint256 currentRate =  _getRate();
        uint256 rBurn = tBurn.mul(currentRate);
        _rOwned[_burnAddress] = _rOwned[_burnAddress].add(rBurn);
        if(_isExcluded[_burnAddress])
            _tOwned[_burnAddress] = _tOwned[_burnAddress].add(tBurn);
    }
    function calculateTaxFee(uint256 _amount) private view returns (uint256) {
        uint256 fee = launchedAt == 0 ? 0 : _taxFee;
        return _amount.mul(fee).div(
            10**2
        );
    }
    function calculateDevFee(uint256 _amount) private view returns (uint256) {
        uint256 fee = launchedAt == 0 ? 0 : _devFee;
        return _amount.mul(fee).div(
            10**2
        );
    }
    function calculateBurnFee(uint256 _amount) private view returns (uint256) {
        uint256 fee = launchedAt == 0 ? _beforeLaunchFee : _burnFee;
        return _amount.mul(fee).div(
            10**2
        );
    }
    function removeAllFee() private {
        if(_taxFee == 0 && _devFee == 0) return;
        
        _previousTaxFee = _taxFee;
        _previousDevFee = _devFee;
        _previousBurnFee = _burnFee;
        _previousBeforeLaunchFee = _beforeLaunchFee;
        
        _taxFee = 0;
        _devFee = 0;
        _burnFee = 0;
        _beforeLaunchFee = 0;
    }
    function restoreAllFee() private {
        _taxFee = _previousTaxFee;
        _devFee = _previousDevFee;
        _burnFee = _previousBurnFee;
        _beforeLaunchFee = _previousBeforeLaunchFee;
    }
    function isExcludedFromFee(address account) public view returns(bool) {
        return _isExcludedFromFee[account];
    }
    function _approve(address owner, address spender, uint256 amount) private {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");
        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) private {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "Transfer amount must be greater than zero");
        require(!isBlacklisted[from], "Blacklisted address");
        if(!_isExcludedFromMax[from] || !_isExcludedFromMax[to]) {
            require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
            uint256 heldTokens = balanceOf(to); 
            require((heldTokens + amount) <= _maxWalletToken, "Total Holding is currently limited, you can not buy that much.");
        }
        
        //indicates if fee should be deducted from transfer
        bool takeFee = true;
        
        //if any account belongs to _isExcludedFromFee account then remove the fee
        if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
            takeFee = false;
        }
        
        //transfer amount, it will take tax, burn fee
        _tokenTransfer(from,to,amount,takeFee);
    }
    function swapTokensForEth(uint256 tokenAmount) private {
        // generate the uniswap pair path of token -> weth
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = uniswapV2Router.WETH();
        _approve(address(this), address(uniswapV2Router), tokenAmount);
        // make the swap
        uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokenAmount,
            0, // accept any amount of ETH
            path,
            address(this),
            block.timestamp
        );
    }
    //this method is responsible for taking all fee, if takeFee is true
    function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
        if(!takeFee)
            removeAllFee();
        
        if (_isExcluded[sender] && !_isExcluded[recipient]) {
            _transferFromExcluded(sender, recipient, amount);
        } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
            _transferToExcluded(sender, recipient, amount);
        } else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
            _transferStandard(sender, recipient, amount);
        } else if (_isExcluded[sender] && _isExcluded[recipient]) {
            _transferBothExcluded(sender, recipient, amount);
        } else {
            _transferStandard(sender, recipient, amount);
        }
        
        if(!takeFee)
            restoreAllFee();
    }
    function _transferStandard(address sender, address recipient, uint256 tAmount) private {
        (uint256 tTransferAmount, uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
        _takeDevFee(tDev);
        _takeBurnFee(tBurn);
        _reflectFee(rFee, tFee);
        emit Transfer(sender, recipient, tTransferAmount);
    }
    function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
        (uint256 tTransferAmount, uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
        _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);           
        _takeDevFee(tDev);
        _takeBurnFee(tBurn);
        _reflectFee(rFee, tFee);
        emit Transfer(sender, recipient, tTransferAmount);
    }
    function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
        (uint256 tTransferAmount, uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        _tOwned[sender] = _tOwned[sender].sub(tAmount);
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);   
        _takeDevFee(tDev);
        _takeBurnFee(tBurn);
        _reflectFee(rFee, tFee);
        emit Transfer(sender, recipient, tTransferAmount);
    }
} | 
	/*
 To be modified before deploying this contract for a project:
 - Uniswap Router address if not on ETH
 - Dev address
 */ | 
	Comment | 
	//to recieve ETH from uniswapV2Router when swapping | 
	LineComment | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    9469,
    9503
  ]
} | 4,690 | ||
| 
	Fubuki | 
	Fubuki.sol | 
	0xf70d834287bbd0324ebb6a5fd20334a16d695256 | 
	Solidity | 
	Fubuki | 
	contract Fubuki is Context, IERC20, Ownable {
    using SafeMath for uint256;
    using Address for address;
    mapping (address => uint256) private _rOwned;
    mapping (address => uint256) private _tOwned;
    mapping (address => mapping (address => uint256)) private _allowances;
    mapping (address => bool) private _isExcludedFromFee;
    mapping (address => bool) private _isExcludedFromMax;
    mapping (address => bool) private _isExcluded;
    mapping (address => bool) isBlacklisted;
    address[] private _excluded;
   
    uint256 private constant MAX = ~uint256(0);
    uint256 private _tTotal = 100000069 * 10**18;
    uint256 private _rTotal = (MAX - (MAX % _tTotal));
    uint256 private _tFeeTotal;
    address private _devAddress = 0xF3C38c8dD73557c03558d56CC1f36DcCB5BA01EC;
    address private _burnAddress = 0x0000000000000000000000000000000000000001;
    string private _name = "Fubuki Token";
    string private _symbol = "FUBUKI";
    uint8 private _decimals = 18;
    
    uint256 public _taxFee = 2;
    uint256 private _previousTaxFee = _taxFee;
    uint256 public _devFee = 5;
    uint256 private _previousDevFee = _devFee;
    uint256 public _burnFee = 2;
    uint256 private _previousBurnFee = _burnFee;
    uint256 private _beforeLaunchFee = 99;
    uint256 private _previousBeforeLaunchFee = _beforeLaunchFee;
    uint256 public launchedAt;
    uint256 public launchedAtTimestamp;
    IUniswapV2Router02 public immutable uniswapV2Router;
    address public uniswapV2Pair;
        
    uint256 public _maxTxAmount = _tTotal.div(200).mul(1);
    uint256 public _maxWalletToken = _tTotal.div(100).mul(1);
        
    constructor () public {
        _rOwned[_msgSender()] = _rTotal;
        
        IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
         // Create a uniswap pair for this new token
        uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
            .createPair(address(this), _uniswapV2Router.WETH());
        // set the rest of the contract variables
        uniswapV2Router = _uniswapV2Router;
        // exclude owner, dev wallet, and this contract from fee
        _isExcludedFromFee[owner()] = true;
        _isExcludedFromFee[address(this)] = true;
        _isExcludedFromFee[_devAddress] = true;
        _isExcludedFromMax[owner()] = true;
        _isExcludedFromMax[address(this)] = true;
        _isExcludedFromMax[_devAddress] = true;
        _isExcludedFromMax[uniswapV2Pair] = true;
        emit Transfer(address(0), _msgSender(), _tTotal);
    }
    function name() public view returns (string memory) {
        return _name;
    }
    function symbol() public view returns (string memory) {
        return _symbol;
    }
    function decimals() public view returns (uint8) {
        return _decimals;
    }
    function totalSupply() public view override returns (uint256) {
        return _tTotal;
    }
    function balanceOf(address account) public view override returns (uint256) {
        if (_isExcluded[account]) return _tOwned[account];
        return tokenFromReflection(_rOwned[account]);
    }
    function transfer(address recipient, uint256 amount) public override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }
    function allowance(address owner, address spender) public view override returns (uint256) {
        return _allowances[owner][spender];
    }
    function approve(address spender, uint256 amount) public override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }
    function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }
    function isExcludedFromReward(address account) public view returns (bool) {
        return _isExcluded[account];
    }
    function setIsBlacklisted(address account, bool blacklisted) external onlyOwner() {
        isBlacklisted[account] = blacklisted;
    }
    function blacklistMultipleAccounts(address[] calldata accounts, bool blacklisted) external onlyOwner() {
        for (uint256 i = 0; i < accounts.length; i++) {
            isBlacklisted[accounts[i]] = blacklisted;
        }
    }
    function isAccountBlacklisted(address account) external view returns (bool) {
        return isBlacklisted[account];
    }
    function isExcludedFromMax(address holder, bool exempt) external onlyOwner() {
        _isExcludedFromMax[holder] = exempt;
    }
    function totalFees() public view returns (uint256) {
        return _tFeeTotal;
    }
    function burnAddress() public view returns (address) {
        return _burnAddress;
    }
    function devAddress() public view returns (address) {
        return _devAddress;
    }
    function launch() public onlyOwner() {
        require(launchedAt == 0, "Already launched.");
        launchedAt = block.number;
        launchedAtTimestamp = block.timestamp;
    }
    function deliver(uint256 tAmount) public {
        address sender = _msgSender();
        require(!_isExcluded[sender], "Excluded addresses cannot call this function");
        (,uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount,,) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _rTotal = _rTotal.sub(rAmount);
        _tFeeTotal = _tFeeTotal.add(tAmount);
    }
    function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
        require(tAmount <= _tTotal, "Amount must be less than supply");
        
        (,uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount, uint256 rTransferAmount,) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        if (!deductTransferFee) {
            return rAmount;
        } else {
            return rTransferAmount;
        }
    }
    function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
        require(rAmount <= _rTotal, "Amount must be less than total reflections");
        uint256 currentRate =  _getRate();
        return rAmount.div(currentRate);
    }
    function excludeFromReward(address account) public onlyOwner() {
        require(!_isExcluded[account], "Account is already excluded");
        if(_rOwned[account] > 0) {
            _tOwned[account] = tokenFromReflection(_rOwned[account]);
        }
        _isExcluded[account] = true;
        _excluded.push(account);
    }
    function includeInReward(address account) external onlyOwner() {
        require(_isExcluded[account], "Account is not excluded");
        for (uint256 i = 0; i < _excluded.length; i++) {
            if (_excluded[i] == account) {
                _excluded[i] = _excluded[_excluded.length - 1];
                _tOwned[account] = 0;
                _isExcluded[account] = false;
                _excluded.pop();
                break;
            }
        }
    }
        
    function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
        (uint256 tTransferAmount, uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        _tOwned[sender] = _tOwned[sender].sub(tAmount);
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
        _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
        _takeDevFee(tDev);
        _takeBurnFee(tBurn);
        _reflectFee(rFee, tFee);
        emit Transfer(sender, recipient, tTransferAmount);
    }
        
    function excludeFromFee(address account) public onlyOwner {
        _isExcludedFromFee[account] = true;
    }
    
    function includeInFee(address account) public onlyOwner {
        _isExcludedFromFee[account] = false;
    }
    
    function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
        _taxFee = taxFee;
    }
    
    function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
        _maxTxAmount = _tTotal.mul(maxTxPercent).div(
            10**2
        );
    }
    function setMaxWalletPercent(uint256 maxWalletToken) external onlyOwner() {
        _maxWalletToken = _tTotal.mul(maxWalletToken).div(
            10**2
        );
    }
    
     //to recieve ETH from uniswapV2Router when swapping
    receive() external payable {}
    function _reflectFee(uint256 rFee, uint256 tFee) private {
        _rTotal = _rTotal.sub(rFee);
        _tFeeTotal = _tFeeTotal.add(tFee);
    }
    function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) {
        uint256 tFee = calculateTaxFee(tAmount);
        uint256 tDev = calculateDevFee(tAmount);
        uint256 tBurn = calculateBurnFee(tAmount);
        uint256 tTransferAmount = tAmount.sub(tFee).sub(tDev);
                tTransferAmount = tTransferAmount.sub(tBurn);
        return (tTransferAmount, tFee, tDev, tBurn);
    }
    function _getRValues(uint256 tAmount, uint256 tFee, uint256 tDev, uint256 tBurn, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
        uint256 rAmount = tAmount.mul(currentRate);
        uint256 rFee = tFee.mul(currentRate);
        uint256 rDev = tDev.mul(currentRate);
        uint256 rBurn = tBurn.mul(currentRate);
        uint256 rTransferAmount = rAmount.sub(rFee).sub(rDev).sub(rBurn);
        return (rAmount, rTransferAmount, rFee);
    }
    function _getRate() private view returns(uint256) {
        (uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
        return rSupply.div(tSupply);
    }
    function _getCurrentSupply() private view returns(uint256, uint256) {
        uint256 rSupply = _rTotal;
        uint256 tSupply = _tTotal;      
        for (uint256 i = 0; i < _excluded.length; i++) {
            if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
            rSupply = rSupply.sub(_rOwned[_excluded[i]]);
            tSupply = tSupply.sub(_tOwned[_excluded[i]]);
        }
        if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
        return (rSupply, tSupply);
    }
    function _takeDevFee(uint256 tDev) private {
        uint256 currentRate =  _getRate();
        uint256 rDev = tDev.mul(currentRate);
        _rOwned[_devAddress] = _rOwned[_devAddress].add(rDev);
        if(_isExcluded[_devAddress])
            _tOwned[_devAddress] = _tOwned[_devAddress].add(tDev);
    }
    function _takeBurnFee(uint256 tBurn) private {
        uint256 currentRate =  _getRate();
        uint256 rBurn = tBurn.mul(currentRate);
        _rOwned[_burnAddress] = _rOwned[_burnAddress].add(rBurn);
        if(_isExcluded[_burnAddress])
            _tOwned[_burnAddress] = _tOwned[_burnAddress].add(tBurn);
    }
    function calculateTaxFee(uint256 _amount) private view returns (uint256) {
        uint256 fee = launchedAt == 0 ? 0 : _taxFee;
        return _amount.mul(fee).div(
            10**2
        );
    }
    function calculateDevFee(uint256 _amount) private view returns (uint256) {
        uint256 fee = launchedAt == 0 ? 0 : _devFee;
        return _amount.mul(fee).div(
            10**2
        );
    }
    function calculateBurnFee(uint256 _amount) private view returns (uint256) {
        uint256 fee = launchedAt == 0 ? _beforeLaunchFee : _burnFee;
        return _amount.mul(fee).div(
            10**2
        );
    }
    function removeAllFee() private {
        if(_taxFee == 0 && _devFee == 0) return;
        
        _previousTaxFee = _taxFee;
        _previousDevFee = _devFee;
        _previousBurnFee = _burnFee;
        _previousBeforeLaunchFee = _beforeLaunchFee;
        
        _taxFee = 0;
        _devFee = 0;
        _burnFee = 0;
        _beforeLaunchFee = 0;
    }
    function restoreAllFee() private {
        _taxFee = _previousTaxFee;
        _devFee = _previousDevFee;
        _burnFee = _previousBurnFee;
        _beforeLaunchFee = _previousBeforeLaunchFee;
    }
    function isExcludedFromFee(address account) public view returns(bool) {
        return _isExcludedFromFee[account];
    }
    function _approve(address owner, address spender, uint256 amount) private {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");
        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) private {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "Transfer amount must be greater than zero");
        require(!isBlacklisted[from], "Blacklisted address");
        if(!_isExcludedFromMax[from] || !_isExcludedFromMax[to]) {
            require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
            uint256 heldTokens = balanceOf(to); 
            require((heldTokens + amount) <= _maxWalletToken, "Total Holding is currently limited, you can not buy that much.");
        }
        
        //indicates if fee should be deducted from transfer
        bool takeFee = true;
        
        //if any account belongs to _isExcludedFromFee account then remove the fee
        if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
            takeFee = false;
        }
        
        //transfer amount, it will take tax, burn fee
        _tokenTransfer(from,to,amount,takeFee);
    }
    function swapTokensForEth(uint256 tokenAmount) private {
        // generate the uniswap pair path of token -> weth
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = uniswapV2Router.WETH();
        _approve(address(this), address(uniswapV2Router), tokenAmount);
        // make the swap
        uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokenAmount,
            0, // accept any amount of ETH
            path,
            address(this),
            block.timestamp
        );
    }
    //this method is responsible for taking all fee, if takeFee is true
    function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
        if(!takeFee)
            removeAllFee();
        
        if (_isExcluded[sender] && !_isExcluded[recipient]) {
            _transferFromExcluded(sender, recipient, amount);
        } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
            _transferToExcluded(sender, recipient, amount);
        } else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
            _transferStandard(sender, recipient, amount);
        } else if (_isExcluded[sender] && _isExcluded[recipient]) {
            _transferBothExcluded(sender, recipient, amount);
        } else {
            _transferStandard(sender, recipient, amount);
        }
        
        if(!takeFee)
            restoreAllFee();
    }
    function _transferStandard(address sender, address recipient, uint256 tAmount) private {
        (uint256 tTransferAmount, uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
        _takeDevFee(tDev);
        _takeBurnFee(tBurn);
        _reflectFee(rFee, tFee);
        emit Transfer(sender, recipient, tTransferAmount);
    }
    function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
        (uint256 tTransferAmount, uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
        _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);           
        _takeDevFee(tDev);
        _takeBurnFee(tBurn);
        _reflectFee(rFee, tFee);
        emit Transfer(sender, recipient, tTransferAmount);
    }
    function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
        (uint256 tTransferAmount, uint256 tFee, uint256 tDev, uint256 tBurn) = _getTValues(tAmount);
        (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tDev, tBurn, _getRate());
        _tOwned[sender] = _tOwned[sender].sub(tAmount);
        _rOwned[sender] = _rOwned[sender].sub(rAmount);
        _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);   
        _takeDevFee(tDev);
        _takeBurnFee(tBurn);
        _reflectFee(rFee, tFee);
        emit Transfer(sender, recipient, tTransferAmount);
    }
} | 
	/*
 To be modified before deploying this contract for a project:
 - Uniswap Router address if not on ETH
 - Dev address
 */ | 
	Comment | 
	_tokenTransfer | 
	function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
    if(!takeFee)
        removeAllFee();
        
    if (_isExcluded[sender] && !_isExcluded[recipient]) {
        _transferFromExcluded(sender, recipient, amount);
    } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
        _transferToExcluded(sender, recipient, amount);
    } else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
        _transferStandard(sender, recipient, amount);
    } else if (_isExcluded[sender] && _isExcluded[recipient]) {
        _transferBothExcluded(sender, recipient, amount);
    } else {
        _transferStandard(sender, recipient, amount);
    }
        
    if(!takeFee)
        restoreAllFee();
}
 | 
	//this method is responsible for taking all fee, if takeFee is true | 
	LineComment | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://dfd7e7ed6489eac8e7c41b6125b0a39d58298c2b36bd66f46857a91853b0164c | 
	{
  "func_code_index": [
    15556,
    16395
  ]
} | 4,691 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	add | 
	function add(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a + b;
    require(c >= a, "SafeMath: addition overflow");
    return c;
}
 | 
	/**
 * @dev Returns the addition of two unsigned integers, reverting on
 * overflow.
 *
 * Counterpart to Solidity's `+` operator.
 *
 * Requirements:
 *
 * - Addition cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    259,
    445
  ]
} | 4,692 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	sub | 
	function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    return sub(a, b, "SafeMath: subtraction overflow");
}
 | 
	/**
 * @dev Returns the subtraction of two unsigned integers, reverting on
 * overflow (when the result is negative).
 *
 * Counterpart to Solidity's `-` operator.
 *
 * Requirements:
 *
 * - Subtraction cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    723,
    864
  ]
} | 4,693 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	sub | 
	function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    require(b <= a, errorMessage);
    uint256 c = a - b;
    return c;
}
 | 
	/**
 * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
 * overflow (when the result is negative).
 *
 * Counterpart to Solidity's `-` operator.
 *
 * Requirements:
 *
 * - Subtraction cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    1162,
    1359
  ]
} | 4,694 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	mul | 
	function mul(uint256 a, uint256 b) internal pure returns (uint256) {
    // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
    // benefit is lost if 'b' is also tested.
    // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
    if (a == 0) {
        return 0;
    }
    uint256 c = a * b;
    require(c / a == b, "SafeMath: multiplication overflow");
    return c;
}
 | 
	/**
 * @dev Returns the multiplication of two unsigned integers, reverting on
 * overflow.
 *
 * Counterpart to Solidity's `*` operator.
 *
 * Requirements:
 *
 * - Multiplication cannot overflow.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    1613,
    2089
  ]
} | 4,695 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	div | 
	function div(uint256 a, uint256 b) internal pure returns (uint256) {
    return div(a, b, "SafeMath: division by zero");
}
 | 
	/**
 * @dev Returns the integer division of two unsigned integers. Reverts on
 * division by zero. The result is rounded towards zero.
 *
 * Counterpart to Solidity's `/` operator. Note: this function uses a
 * `revert` opcode (which leaves remaining gas untouched) while Solidity
 * uses an invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 *
 * - The divisor cannot be zero.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    2560,
    2697
  ]
} | 4,696 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	div | 
	function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    require(b > 0, errorMessage);
    uint256 c = a / b;
    // assert(a == b * c + a % b); // There is no case in which this doesn't hold
    return c;
}
 | 
	/**
 * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
 * division by zero. The result is rounded towards zero.
 *
 * Counterpart to Solidity's `/` operator. Note: this function uses a
 * `revert` opcode (which leaves remaining gas untouched) while Solidity
 * uses an invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 *
 * - The divisor cannot be zero.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    3188,
    3471
  ]
} | 4,697 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	mod | 
	function mod(uint256 a, uint256 b) internal pure returns (uint256) {
    return mod(a, b, "SafeMath: modulo by zero");
}
 | 
	/**
 * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
 * Reverts when dividing by zero.
 *
 * Counterpart to Solidity's `%` operator. This function uses a `revert`
 * opcode (which leaves remaining gas untouched) while Solidity uses an
 * invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 *
 * - The divisor cannot be zero.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    3931,
    4066
  ]
} | 4,698 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	SafeMath | 
	library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
} | 
	/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */ | 
	NatSpecMultiLine | 
	mod | 
	function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
    require(b != 0, errorMessage);
    return a % b;
}
 | 
	/**
 * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
 * Reverts with custom message when dividing by zero.
 *
 * Counterpart to Solidity's `%` operator. This function uses a `revert`
 * opcode (which leaves remaining gas untouched) while Solidity uses an
 * invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 *
 * - The divisor cannot be zero.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    4546,
    4717
  ]
} | 4,699 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */ | 
	NatSpecMultiLine | 
	totalSupply | 
	function totalSupply() external view returns (uint256);
 | 
	/**
 * @dev Returns the amount of tokens in existence.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    94,
    154
  ]
} | 4,700 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */ | 
	NatSpecMultiLine | 
	balanceOf | 
	function balanceOf(address account) external view returns (uint256);
 | 
	/**
 * @dev Returns the amount of tokens owned by `account`.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    237,
    310
  ]
} | 4,701 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */ | 
	NatSpecMultiLine | 
	transfer | 
	function transfer(address recipient, uint256 amount) external returns (bool);
 | 
	/**
 * @dev Moves `amount` tokens from the caller's account to `recipient`.
 *
 * Returns a boolean value indicating whether the operation succeeded.
 *
 * Emits a {Transfer} event.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    534,
    616
  ]
} | 4,702 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */ | 
	NatSpecMultiLine | 
	allowance | 
	function allowance(address owner, address spender) external view returns (uint256);
 | 
	/**
 * @dev Returns the remaining number of tokens that `spender` will be
 * allowed to spend on behalf of `owner` through {transferFrom}. This is
 * zero by default.
 *
 * This value changes when {approve} or {transferFrom} are called.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    895,
    983
  ]
} | 4,703 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */ | 
	NatSpecMultiLine | 
	approve | 
	function approve(address spender, uint256 amount) external returns (bool);
 | 
	/**
 * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
 *
 * Returns a boolean value indicating whether the operation succeeded.
 *
 * IMPORTANT: Beware that changing an allowance with this method brings the risk
 * that someone may use both the old and the new allowance by unfortunate
 * transaction ordering. One possible solution to mitigate this race
 * condition is to first reduce the spender's allowance to 0 and set the
 * desired value afterwards:
 * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
 *
 * Emits an {Approval} event.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    1647,
    1726
  ]
} | 4,704 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	IERC20 | 
	interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);
    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);
    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);
    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
} | 
	/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */ | 
	NatSpecMultiLine | 
	transferFrom | 
	function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
 | 
	/**
 * @dev Moves `amount` tokens from `sender` to `recipient` using the
 * allowance mechanism. `amount` is then deducted from the caller's
 * allowance.
 *
 * Returns a boolean value indicating whether the operation succeeded.
 *
 * Emits a {Transfer} event.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    2039,
    2141
  ]
} | 4,705 | 
| 
	Authmen | 
	Authmen.sol | 
	0x89aeca7d3cc04f50e9d2bb635ad84fe8f7e77a9d | 
	Solidity | 
	ERC20 | 
	contract ERC20 is Context, IERC20 {
    using SafeMath for uint256;
    mapping (address => uint256) private _balances;
    mapping (address => mapping (address => uint256)) private _allowances;
    uint256 private _totalSupply;
    string private _name;
    string private _symbol;
    uint8 private _decimals;
    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }
    /**
     * @dev Returns the name of the token.
     */
    function name() public view returns (string memory) {
        return _name;
    }
    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view returns (string memory) {
        return _symbol;
    }
    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view returns (uint8) {
        return _decimals;
    }
    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view override returns (uint256) {
        return _totalSupply;
    }
    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view override returns (uint256) {
        return _balances[account];
    }
    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }
    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }
    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }
    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }
    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }
    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }
    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        _beforeTokenTransfer(sender, recipient, amount);
        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }
    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");
        _beforeTokenTransfer(address(0), account, amount);
        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }
    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");
        _beforeTokenTransfer(account, address(0), amount);
        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }
    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");
        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }
    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal {
        _decimals = decimals_;
    }
    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | 
	/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */ | 
	NatSpecMultiLine | 
	name | 
	function name() public view returns (string memory) {
    return _name;
}
 | 
	/**
 * @dev Returns the name of the token.
 */ | 
	NatSpecMultiLine | 
	v0.6.12+commit.27d51765 | 
	MIT | 
	ipfs://e8b107b27904a2c18838844d3321f3b8812c285a7dde18e816b29dd5fec9faf7 | 
	{
  "func_code_index": [
    874,
    962
  ]
} | 4,706 | 
			Subsets and Splits
				
	
				
			
				
No community queries yet
The top public SQL queries from the community will appear here once available.
