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
        );
    }
}
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: Enter the auction lobby for the current round	
 * @param referrerAddr TRX address of referring user (optional; 0x0 for no referrer)	
 */