SOAP
Last updated
Last updated
SOAP, or Sum of All Payoffs, is essentially a snapshot view of the unrealized P&L of all open positions against the pool. It is the amount that the Liquidity Pool would be liable to payout should all the swaps be closed immediately.
Tracking multiple portfolio positions using traditional computation is pretty straightforward. However, doing it on the blockchain requires a different approach due to computational cost. The IPOR AMM keeps track of each derivative by bundling all derivatives from a given leg into one virtual derivative. Every time the swap is opened or closed, its fixed interest rate is added to the "virtual" swap interest rate. Its notional value is used to calculate the weight of the interest rate.
Where
I - is the interest rate of the "virtual" swap at the time of "n"
N - is notional of the "virtual" swap at the time of "n"
Is - is the interest rate of the newly opened swap
Ns - is the notional amount of freshly opened derivative
Calculating a "virtual" swap after closing a swap is the same, only + changes to -.
Once the attributes of the "virtual swap" are calculated, we can then move to the floating rate as each IPOR swap is a difference in the cash flow between fixed and floating interest rates.
Monitoring the floating interest rate is done through "IBT" or Interest Bearing Token. IBT is not a token that you can own; instead, it accounts for the floating interest rate over time. All interest rate swaps have their notional amount denominated in IBT to account for the floating interest rate.
Where IPOR is the IPOR rate at the time of calculating the IBT value adjusted for delta time.
Every time the swap is opened or closed, it gets assigned with the amount of IBT reflecting its notional size.
A swap's notional denominated in IBT will grow with the floating rate. Thanks to this mechanism, the floating rate part of each swap are straightforward to calculate. We multiply IBT token count specific to a given derivative. Because in SOAP, we want to calculate the "aggregate" swap to track the whole portfolio; we have to add all of the IBT tokens together for a given leg - this represents the floating leg.
The net payout would be the difference between interest generated by the fixed and floating legs in the delta time. It is, however, a little problematic to efficiently calculate it. We would need to track somehow the "average" entry-level of IBT for all derivatives, similar to what is done with the fixed rate. Alternatively, we could follow the interest accrued between each rebalance triggered every time swap is opened or closed. It then becomes a lot easier:
Where
N is the amount of notional from the last rebalancing
R is the average fixed rate at the time of the previous rebalancing
This simple calculation allows us to count the liability of opened swaps at the time of rebalancing. The interest "accrued" on the floating rate is cached and updated at each rebalancing.
The last step is to account for the interest generated in between each rebalancing, but at this point, it is pretty straightforward. Since the IBT calculation is done in the same way, the fixed interest rate can be easily calculated for any given moment; we can then recycle the same formula to know precisely the state of the liabilities at any given moment.
Currently, SOAP is used in two places:
when calculating the worth of liquidity tokens (seem more in the liquidity section)
when assessing the risk of the liquidity pool