contract PoolStakeFactory {
    
    //array of PoolStake contracts
    address[] private _poolStakes;
    
    //event on contract creation
    event Created(address indexed Creator, address Contract, address indexed Token);
    
    /* 
     * @dev get the length of all contracts created 
     * -----------------------------------------------------------
     * returns number of contracts created
     */ 
    function totalContracts() external view returns(uint256) {
        
        return _poolStakes.length;
    }
    
    /* 
     * @dev get an array of all contracts created 
     * -----------------------------------------------------------
     * returns all contracts created 
     */ 
    function getContracts() external view returns(address[] memory) {
        
        return _poolStakes;
    }
    
    /* 
     * @dev create a new contract prototype.
     * -------------------------------------
     * @param _token      --> the ETH-pair token address
     * -------------------------------------------------
     * returns whether successfully changed or not.
     */ 
    function createContract(address _token) external returns(bool) {
            
        PoolStake poolStake = new PoolStake(_token, msg.sender);
        _poolStakes.push(address(poolStake));
        
        emit Created(msg.sender, address(poolStake), _token);
        return true;
    }

}
function totalContracts() external view returns(uint256) {
        
    return _poolStakes.length;
}

/* 
 * @dev get the length of all contracts created 
 * -----------------------------------------------------------
 * returns number of contracts created
 */