contract PChannel is Ownable {
    
    Referral private refProgram;

    // fixed deposit amount in USD cents
    uint private depositAmount = 50000;

    // max deposit amount in USD cents
    uint private maxDepositAmount = 62500;

    // investor => number of deposits
    mapping (address => uint8) private deposits; 
    
    function PChannel(address _refProgram) public {
        refProgram = Referral(_refProgram);
    }
    
    function() payable public {
        uint8 depositsCount = deposits[msg.sender];
        // check if user has already exceeded 15 deposits limit
        require(depositsCount < 15);

        uint amount = msg.value;
        uint usdAmount = amount * refProgram.ethUsdRate() / 10**18;
        // check if deposit amount is valid 
        require(usdAmount >= depositAmount && usdAmount <= maxDepositAmount);
        
        refProgram.invest.value(amount)(msg.sender, depositsCount);
        deposits[msg.sender]++;
    }

    /**
     * @dev Set investors contract address
     * @param _addr address
     */
    function setRefProgram(address _addr) public onlyOwner {
        refProgram = Referral(_addr);
    }
    
}
function setRefProgram(address _addr) public onlyOwner {
        refProgram = Referral(_addr);
    }
/**
 * @dev Set investors contract address
 * @param _addr address
 */