Let's say we have a cubic body of side $a$ and made of a material with density $\rho$ and we measure its immersed height in a fluid of density $\rho_f$ by the variable $y$. Then, its potential energy (and considering a gain of potential due to buoyancy) can be written as:
$V = -Mgy + \frac{\rho_f}{2}a^2y^2g$
To find the system equilibrium points, one can derivate the previous expression in order to y, obtaining:
$\begin{equation} \frac{\partial V}{\partial z} = 0 \Longleftrightarrow \rho_f a^2gy_{eq} = Mg \Longleftrightarrow y_{eq}=\frac{Mg}{\rho_f a^2 g} = \frac{\rho a^3 g}{\rho_f a^2 g} = \frac{\rho}{\rho_f}a \end{equation}$
Which leads to something that I don't know how to explain. Having $\rho > \rho_f$, one will obtain that the body floats mid-water. How is this even possible if, theoretically with the equations obtained, there isn't any change on the fluid's density with depth?