We show that reductions of KP hierarchies related to the loop algebra of $SL_n$ with homogeneous gradation give solutions of the Darboux-Egoroff system of PDEs. Using explicit dressing matrices of the Riemann-Hilbert problem generalized to include a set of commuting additional symmetries, we construct solutions of the Witten--Dijkgraaf--E. Verlinde--H. Verlinde equations.