---
# System prepended metadata

title: Manipulating value of Uni V3 position

---

---
title: Manipulating value of Uni V3 position
---

## Manipulating value of Uni V3 position

Suppose you have a position with lower tick $i_l$ and upper tick $i_u$, and the current tick is $i_c$. Also, suppose you have provided $L$ liquidity into this position. Consider `token1` to be a stable coin (worth $1 USD). If $i_c$ is between $i_l$ and $i_u$, then the amount of `token0` and amount of `token1` you have are:

\begin{align}
a_0 &= L\cdot(\frac{1}{\sqrt{p(i_c)}}-\frac{1}{\sqrt{p(i_u)}}) \\
a_1 &= L \cdot(\sqrt{p(i_c)}-\sqrt{p(i_l)})
\end{align}


### Manipulating to higher tick
If you manipulate the spot price to move to a tick $j$ such that $j > i_u$, then you have amounts:

\begin{align}
b_0 &= 0 \\
b_1 &= L \cdot(\sqrt{p(i_u)}-\sqrt{p(i_l)})
\end{align}

Even though we manipulated the spot price of the pool, we know the _actual_ price is $p(i_c)$ (this could also come from chainlink or some other source, but for simplicity assume that the actual valid price is $p(i_c)$). The dollar amount of the unmanipulated position is $p(i_c)\cdot a_0 + a_1$. The dollar amount of the manipulated position is $p(i_c)\cdot b_0 + b_1 = b_1$. So, the manipulation increases by:
\begin{align}
\frac{b_1}{p(i_c)a_0+a_1} &= \frac{L \cdot(\sqrt{p(i_u)}-\sqrt{p(i_l)})}{p(i_c)L\cdot(\frac{1}{\sqrt{p(i_c)}}-\frac{1}{\sqrt{p(i_u)}})+L \cdot(\sqrt{p(i_c)}-\sqrt{p(i_l)})} \\
&= \frac{\sqrt{p(i_u)}-\sqrt{p(i_l)}}{p(i_c)(\frac{1}{\sqrt{p(i_c)}}-\frac{1}{\sqrt{p(i_u)}})+(\sqrt{p(i_c)}-\sqrt{p(i_l)})} \\
&= \frac{\sqrt{p(i_u)}-\sqrt{p(i_l)}}{\frac{p(i_c)\sqrt{p(i_u)}-p(i_c)\sqrt{p(i_c)}+\sqrt{p(i_c)}\sqrt{p(i_u)}-\sqrt{p(i_c)}\sqrt{p(i_u)}\sqrt{p(i_l)}\sqrt{p(i_c)}}{\sqrt{p(i_c)}\sqrt{p(i_i)}}} \\
&= \frac{\sqrt{p(i_u)}\sqrt{p(i_u)}-\sqrt{p(i_l)}\sqrt{p(i_u)}}{\sqrt{p(i_c)}\sqrt{p(i_u)}-p(i_c)+\sqrt{p(i_c)}\sqrt{p(i_u)}-\sqrt{p(i_l)}\sqrt{p(i_u)}} \\
&= \frac{(\sqrt{p(i_u)}-\sqrt{p(i_c)})^2}{\sqrt{p(i_c)}(2\sqrt{p(i_u)}-\sqrt{p(i_c)})-\sqrt{p(i_l)}\sqrt{p(i_u)}} + 1 \\
\end{align}


Consider the following example where `token0` is ETH:

ETH is worth $1000 USD. An LP position has lower tick price $800 and upper tick price $1400. If the pool was to be manipulated above $1400, the above would tell us that the "value" of the position would be increased by $\frac{(\sqrt{1400}-\sqrt{1000})^2}{\sqrt{1000}(2\sqrt{1400}-\sqrt{1000})-\sqrt{800}\sqrt{1400}} + 1 \approx 1.1089$, so you can instantly increase the "value" of the LP position by 10% by manipulating the spot price.