# Overlay: OI vs OI + PnL
It seems that for the reisk estimation purposes, the Overlay protocol should use $\mathrm{OI} + \mathrm{PnL}$ as a metrica of market exposure, rather than just $\mathrm{OI}$. The rationale is described below.
## Long Position
At the time moment $t_0$ a long position is opened with the collateral amount $N$, the leverage $L$, the open interest $\mathrm{OI} = NL$, and the debt $D = \mathrm{OI} - N = N (L - 1)$. The underlying asset price at this moment is $P(t_0)$.
After a while, at the time moment $t$, the $\mathrm{PnL}$ for this positions is:
$$
\mathrm{PnL} (t_0, t) = \mathrm{OI} \cdot \left( \frac{P(t)}{P(t_0)} - 1 \right)
$$
Now, an additional time period $\tau$ passes. The **additional** $\mathrm{PnL}$ is:
$$
\mathrm{PnL} (t, t + \tau) =
\mathrm{PnL} (t_0, t + \tau) - \mathrm{PnL} (t_0, t) =\\=
\mathrm{OI} \cdot \left( \frac{P(t + \tau)}{P(t_0)} - 1 \right) - \mathrm{OI} \cdot \left( \frac{P(t)}{P(t_0)} - 1 \right) =\\=
\mathrm{OI} \cdot \left( \frac{P(t + \tau) - P(t)}{P(t_0)} \right) =\\=
\mathrm{OI} \cdot \frac{P(t)}{P(t_0)} \cdot \left( \frac{P(t + \tau)}{P(t)} - 1 \right)
$$
Note, than:
$$
\mathrm{OI} \cdot \frac{P(t)}{P(t_0)} = \mathrm{OI} + \mathrm{OI} \cdot \left( \frac{P(t)}{P(t_0)} - 1 \right) = \mathrm{OI} + \mathrm{PnL} (t_0, t)
$$
So, from the future $\mathrm{PnL}$ perspective, a long position opened in the past is equivalent to a position opened just now, whose open interest is the past position's open interst plus past position's unrealized PnL.
Thus, it would be reasonable for the protocol to treat long positions opened in the past as positions opened just now but with unrealized PnL added to the open interest.
## Short Position
At the time moment $t_0$ a short position is opened with the collateral amount $N$, the leverage $L$, the (negative) open interest $\mathrm{OI} = -NL$, and the (negative) debt $D = \mathrm{OI} - N = -N(L + 1)$. The underlying asset price at this moment is $P(t_0)$.
After a while, at the time moment $t$, the $\mathrm{PnL}$ for the position is:
$$
\mathrm{PnL} (t_0, t) = -\mathrm{OI} \cdot \left( 1 - \frac{P(t)}{P(t_0)}\right) =
$$
Now, an additional time period $\tau$ passes. The ** additional$$ $\mathrm{PnL}$ is:
$$
\mathrm{PnL} (t, t + \tau) =
\mathrm{PnL} (t_0, t + \tau) - \mathrm{PnL} (t_0, t) =\\=
-\mathrm{OI} \cdot \left( 1 - \frac{P(t + \tau)}{P(t_0)}\right) - \left( -\mathrm{OI} \cdot \left( 1 - \frac{P(t)}{P(t_0)}\right) \right) =\\=
-\mathrm{OI} \cdot \left( \frac{P(t) - P(t + \tau)}{P(t_0)} \right) =\\=
-\mathrm{OI} \cdot \frac{P(t)}{P(t_0)} \cdot \left( 1 - \frac{P(t + \tau)}{P(t)} \right)
$$
Note, that:
$$
\mathrm{OI} \cdot \frac{P(t)}{P(t_0)} = \mathrm{OI} + \left( -\mathrm{OI} \cdot \left( 1 - \frac{P(t)}{P(t_0)}\right) \right) = \mathrm{OI} + \mathrm{PnL} (t_0, t)
$$
So, from the future $\mathrm{PnL}$, a short position opened in the past is equivalent to a short position opened just now, whose (negative) open interest is the past positions's (negative) open interest plus the past positions's unrealized $\mathrm{PnL}$.
## Conclusion
Taking above into account, it would be reasonable for the protocol to treat positions open in the past as if these positions were opened just now and their unrealized $\mathrm{PnL}$ values were added to their open interest values.