owned this note
owned this note
Published
Linked with GitHub
# Pricing Principal Tokens
To calculate the present value of a fixed yield token, we can use the annualized yield formula referenced in the Yield Protocol's [paper](https://yield.is/Yield.pdf):
\begin{equation}
Y=\left(\frac{F}{P}\right)^{\frac{1}{T}}-1\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad(1)
\end{equation}
where $Y$ is the annualized yield, $F$ is the face value, $P$ is the present value and $T$ is the time until maturity. The terms can be rearranged to solve for present value:
\begin{equation}
P=\frac{F}{(Y+1)^{T}}\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\;\;\;\;(2)
\end{equation}
In the next section, we will use the present value to calculate what the market will pay, in terms of the base asset, for a Principal Token (PT) at time $T$.
## Pricing PTs with Different Maturities
Pricing a PT so that it can be swapped for it's base asset is fairly intuitive. The same intuition can be used to get a sense of how we can price PTs of different maturities. If we want to swap a $PT_{1}$ for a $PT_{2}$, the question we actually want to answer is:
*How many $PT_{2}$'s is one $PT_{1}$ worth?*
which is equivalent to the following equation:
\begin{equation}
\frac{F_1}{(Y_1+1)^{T_1}}=n\ \cdot \frac{F_2}{(Y_2+1)^{T_2}}\qquad\qquad\qquad\qquad\qquad\qquad(3)
\end{equation}
Solving for $n$:
\begin{equation}
n=\frac{F_1\left(Y_2+1\right)^{T_{2}}}{F_2\left(Y_1+1\right)^{T_{1}}}\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\;\;\;(4)
\end{equation}
Since the present value formula (2) gives us the price of a $PT$ in terms of $ETH$, we can substitute the $PT$ present value in equation (3) with the price in terms of $ETH$ in order to confirm that we end up with the correct units:
\begin{aligned}
\require{cancel}
\frac{PT_1}{ETH}&=n\ \cdot \frac{PT_2}{ETH}\\
\end{aligned}
solving for $n$:
\begin{aligned}
\require{cancel}
n&=\frac{PT_1}{\bcancel{ETH}} \cdot\frac{\bcancel{ETH}}{PT_2}\\
&=\frac{PT_1}{PT_2}\;\;\;\;{\unicode{x2714}}
\end{aligned}
## Implementing a Principle Token (PT) Market
The [yield space paper](https://yield.is/YieldSpace.pdf) introduces the following invariant called the *constant power sum invariant* that accounts for time until maturity to ensure stable interest rates on PTs.
\begin{equation}
x^{1-t}+y^{1-t}=k\qquad\qquad\qquad\qquad\qquad\;\;\;\;\;\;(5)
\end{equation}
where $x$ is the reserves of the base asset, $y$ is the reserves of the PT, $t$ is the time to maturity and $k$ is a constant. A small modification can be made to (5) to demonstrate how it can be used to calculate the price of outgoing assets in terms of incoming assets:
\begin{equation}
(out_r-out_q)^{1-t}+(in_r+in_q)^{1-t}=k\qquad\;\;(6)
\end{equation}
where $out_r$ is the reserves of the outgoing asset, $out_q$ is the quantity of the outgoing asset, $in_r$ is the reserves of the incoming asset, $in_q$ is the quantity of the incoming asset, $t$ is the time to maturity and $k$ is a constant
### Calculate Out Given In
If a user whats to know how much of an asset they will receive for to input for some input quantity, then we solve (6) for $out_q$:
\begin{equation}
CalcOutGivenIn(out_r,in_r,in_q,k,t)=out_r-\left(k-\left(in_r+in_q\right)^{\left(1-t\right)}\right)^{\frac{1}{1-t}}\qquad\qquad(7)
\end{equation}
If the output is base tokens, the fee earned by LPs is calculated as follows:
\begin{equation}
fee = (in_q - CalcOutGivenIn(out_r,in_r,in_q,k,t))\ \times\ \phi
\end{equation}
where $\phi$ represents the percent fee charged on the price spread.
If the output is PTs, the fee earned by LPs is calculated as follows:
\begin{equation}
fee = (CalcOutGivenIn(out_r,in_r,in_q,k,t) - in_q)\ \times\ \phi
\end{equation}
where $\phi$ represents the percent fee charged on the price spread.
### Calculate In Given Out
If a user whats to know how much of an asset to input for the desired amount of output, then we solve (6) for $in_q$:
\begin{equation}
CalcInGivenOut(out_r,in_r,out_q,k,t)=\left(k-\left(out_r-out_q\right)^{\left(1-t\right)}\right)^{\frac{1}{1-t}}-in_r\qquad\qquad(8)
\end{equation}
If the input is base tokens, the fee earned by LPs is calculated as follows:
\begin{equation}
fee = (out_q - CalcInGivenOut(out_r,in_r,out_q,k,t))\ \times\ \phi
\end{equation}
where $\phi$ represents the percent fee charged on the price spread.
If the input is PTs, the fee earned by LPs is calculated as follows:
\begin{equation}
fee = (CalcOutGivenIn(out_r,in_r,out_q,k,t) - out_q)\ \times\ \phi
\end{equation}
where $\phi$ represents the percent fee charged on the price spread.
### Virtual Reserve logic
Equation (5) allocates some portion of the reserves for PT prices greater than 1 and since our pool has logic preventing this from happening, these reserves are essentially wasted on a price that isn't discoverable. As a result, we use the virtual reserve logic described in section 6.3 of the [yield space paper](https://yield.is/YieldSpace.pdf) to encrease the capital efficiency of the pool. Implementing this logic to price PTs in terms of base assets (and vice versa) is just a matter of calling (7) or (8) with additional reserves added to the parameter representing the PT.
For example, to calculate the number of base tokens that 100 PTs is worth, you would invoke (7) as follows:
\begin{equation}
CalcOutGivenIn(out_r,in_r,in_q,k,t)
\end{equation}
where
\begin{aligned}
\require{cancel}
out_r&= Base\ reserves\\
in_r&= PT\ reserves + Pool\ Liquidity\ Shares\\
in_q&= PT\ input\ quantity
\end{aligned}