# Max amount in before price goes above a certain value
Given amounts $x_1$ and $y_1$
Price of $x$ in $y$, $p_1 = \frac{y_1}{x_1}$
What is $\Delta y$ at which price goes above given $p_2$?
Let
$$
\begin{align*}
y_2 &= y_1 + \Delta y\\
x_2 &= \frac{x_1y_1}{y_1 + \Delta y}
\end{align*}
$$
Solve for $\Delta y$ such that
\begin{align*}
p_2 &= \frac{y_2}{x_2}\\
&= \frac{(y_1 + \Delta y)^2}{x_1y_1}\\
\end{align*}
Rearranging, we get
$$
\Delta y = \sqrt{p_2 x_1 y_1} - y_1
$$