IPOR Protocol
  • The IPOR Protocol Documentation
  • IPOR Protocol V2
  • Research / Whitepapers
    • Conceptual Whitepaper
  • Audits
  • Community Links
  • IPOR Protocol Roadmap
  • IPOR FAQ
    • About the IPOR Protocol
    • Using the IPOR Protocol
    • Liquidity Mining
    • Swaps VS Perps
    • $FUSN Snapshot
  • About IPOR
    • Who Uses IPOR and for What?
    • Why IPOR?
    • IPOR Manifesto
  • IPOR Fusion ⚛️
    • Fusion Introduction
      • Defragmenting DeFi Yield
    • Why Fusion?
    • Users
    • Use Cases
    • Architecture Overview
      • Atomists
      • Alphas
    • Vaults
      • Access Management
    • Fuses
    • Security
      • For Liquidity Providers
      • For Vault Owners
      • Testing
    • Open-source Repository
    • Aragon Integration
  • IPOR Index
    • What is the IPOR Index
    • Working with the IPOR Index
    • IPOR stETH Index
  • Interest Rate Derivatives
    • Interest Rate Derivative
    • Index Calculation
    • IPOR Publication
    • IBT
    • Indicative Term Sheet
  • Automated Market Maker
    • The Automated Market Maker
    • Liquidity Provisioning
    • IPOR Swaps
      • Hedging example with Morpho protocol
    • Spread
      • Math behind the demand spread
    • Risk oracle
    • SOAP
    • Liquidations
    • Asset Management
  • Tokenomics
    • IPOR Token
    • Token distribution model
    • Power IPOR
    • Liquidity mining
      • Math behind the rewards contract
    • Power Token Liquidity Mining for Developers
  • IPOR DAO
    • IPOR DAO Governance
      • Discord - All Channels
      • Discord - Open Governance Forum
      • Discord - Formal Governance
      • Snapshot - Formal Governance
      • Governing Multisig wallets
    • Decentralizing IPOR
      • Configuration Parameters
  • Developers Docs
    • Fusion
      • Developing а Fuse
      • Configuring Pre-hooks
    • Deployed Contracts
      • Ethereum
      • Arbitrum
      • Base
    • Working with IPOR Router
    • ABI
    • V2 changes
    • IPOR Oracle
    • Vault Wrapper
Powered by GitBook
On this page
  • What is SOAP?
  • How is SOAP calculated?
  • Use of SOAP

Was this helpful?

Edit on GitHub
  1. Automated Market Maker

SOAP

PreviousRisk oracleNextLiquidations

Last updated 1 year ago

Was this helpful?

What is SOAP?

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.

How is SOAP calculated?

Fixed Interest Rate

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.

In=In−1∗Nn−1+Is∗NsNn−1+NsI_{n} = \frac{I_{n-1} * N_{n-1} + I_{s} * N_{s}}{N_{n-1} + N_{s}}In​=Nn−1​+Ns​In−1​∗Nn−1​+Is​∗Ns​​

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.

Floating Interest Rate

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.

Putting it all together

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.

Use of SOAP

Currently, SOAP is used in two places:

  • when assessing the risk of the liquidity pool

IBTnew=IBTold⋅eIPOR⋅ΔTTYearIBT_{new} = IBT_{old} \cdot e ^{\frac{IPOR \cdot \Delta T}{T_{Year}}} IBTnew​=IBTold​⋅eTYear​IPOR⋅ΔT​
NIBT=NIBTN_{IBT} = \frac{N}{IBT}NIBT​=IBTN​
SOAPpayFixedn=SOAPn−1+NIBT⋅IBTprice−Nn−1⋅eR∗ΔTTyearSOAP_{payFixed_{n}} = SOAP_{n-1} + N_{IBT} \cdot IBT_{price} - N_{n-1} \cdot e^{\frac{R * \Delta T}{T_{year}}}SOAPpayFixedn​​=SOAPn−1​+NIBT​⋅IBTprice​−Nn−1​⋅eTyear​R∗ΔT​
SOAPreceiveFixedn=SOAPn−1+N⋅eR∗ΔTTyear−NIBT⋅IBTpriceSOAP_{receiveFixed_n} = SOAP_{n-1} + N \cdot e^{\frac{R * \Delta T}{T_{year}}} - N_{IBT} \cdot IBT_{price}SOAPreceiveFixedn​​=SOAPn−1​+N⋅eTyear​R∗ΔT​−NIBT​⋅IBTprice​
SOAP=SOAPpayFixedN+SOAPreceiveFixednSOAP = SOAP_{payFixed_{N}} + SOAP_{receiveFixed_{n}}SOAP=SOAPpayFixedN​​+SOAPreceiveFixedn​​

when calculating the worth of liquidity tokens (seem more in the )

liquidity section