# IPOR Swaps

Interest Rate Derivatives in IPOR as a whole refer to any derivative instrument that uses an IPOR Index value as a contract reference. In the future, there could be multiple types of derivative instruments and contracts which use the IPOR Index as a benchmark rate.

The IPOR Interest Rate Swap (IRS) is the cornerstone derivative product of IPOR. The IRS allows a market participant to be a Payer or Receiver and take a contract against the liquidity pool. For more detailed information about participants and contracts, reference here.

Once a Payer or Receiver agrees to a contract quoted by the AMM, they will pay the collateral amount (margin), the contract fee, and applicable network fees (i.e., in the case of Ethereum, some ETH must be used to pay for network gas fees) to enter into a derivative smart contract. The liquidity pool will reserve an equal collateral amount to cover all payoff obligations. Over time the contract will manage the positions and payoffs. Once closed, it will pay the respective sum(s) to the parties.

**What is notional?**

Notional is the total value of the position that the market participant takes. This should not be confused with collateral. The notional value of derivative contracts is higher than the market value depending on the amount of leverage.

The IPOR Protocol currently allows the opening of so-called vanilla swaps. That means that traders and LPs are exchanging two streams of cash flow:

- interest calculated based on the fixed interest rate
- interest calculated based on the floating (sometimes termed variable) interest rate. (see IBT to learn how the floating is tracked )

Let's consider two possible directions of the interest rate swap that you can open on the IPOR protocol:

- Pay fixed, receive floating
- Receive fixed, pay floating

In Pay Fixed, you are responsible for paying the fixed interest on the notional of your trade, and the AMM will be paying you the floating interest rate determined by IPOR (every time where floating rate is concerned, the IPOR is used). The net difference between what you pay and receive is your P&L.

In Receive Fixed, the flow is reversed.

Let's use an example of a trader who wants to hedge their loan using the IPOR rate as a benchmark between different platforms.

- 1.Trader takes a loan of 1.000.000 USDC at a 3.00% floating rate (at the time of opening) and is liable to pay interest on this loan.
- 2.Trader opens swap Pay Fixed - Receive Floating at 3.12% (the fixed rate).
- 3.Scenario 1: During maturity of the loan/swap, interest rates were, on average 3.95%
- 1.The trader had to pay additional interest on their loan.
- 2.Trader accrued interest on the swap that should cover the majority of their loss in the form of extra borrowing cost on the loan

- 4.Scenario 2: During maturity of the loan/swap, interest rates were, on average 2.55%
- 1.The trader paid a lower interest on their loan (compared to what they would have paid at 3.00% - the original rate)
- 2.The trader has accrued a loss on their derivative that should be covered by the savings he made on loan.

A trader's payoff at the time of the derivative closing is determined by the difference between their fixed and floating legs. In cases of both floating and fixed, it is the Notional Amount of the derivative that is used to calculate the amount of interest.

**Fixed leg interest**

$\alpha_{fix} = N * (1+IR_{fix})* \frac{\Delta T}{T}$

**Floating leg interest**

$\alpha_{floating} = \frac {N}{IBT_{n-1}} * IBT_{n}$

The net payout depends on the leg.

**Pay fixed - Receive Floating.**

$\alpha_{net} = \alpha_{floating} - \alpha_{fix}$

**Receive fixed - Pay Floating**

$\alpha_{net} = \alpha_{fix}-\alpha_{floating}$

Note that IBT

*{n-1} is the value of IBT at the time when the swap was opened, and IBT*{n} is the IBT's price at the time of swap closing. N is the notional amount, and IR is the fixed interest rate at which the swap was opened.Spread is one way for the AMM to control the risk and essentially price it to the traders. By exchanging one rate for another with the pool, traders effectively transfer risk to the liquidity pool. That service provided by the AMM and Liquidity pool is priced in the form of a spread. For more details, refer to the spread section of this documentation.

The AMM charges a couple of fees that are summed up at the time the swap is opened:

**The opening fee**is calculated based on the collateral put forward in the swap. The DAO sets the fee's rate, and the inception value is 1% of collateral. This fee is paid to the LP pool as compensation for underwriting the derivative's risk.**Base flat fee**- the rate is set by the DAO. Proceeds from the flat base fee are used predominantly to subsidize the oracle. Once the oracle starts generating more ways to be supported, this fee will be phased out.**Income Fee**- when the derivative is closed, part of the profit (from the trader or LP) is set aside for the treasury of the DAO. At inception, the fee amount is 10%; after that, the DAO is responsible for setting the fee rate.

At the time of writing this documentation, IPOR Protocol offers swaps with a 28-day maturity (or four weeks). This means that the swap will be up for liquidation once 28 days have elapsed since the derivative has been opened. The contract is open for liquidation 6 hours before maturity. It will continue to accrue interest until it is either closed by the trader or liquidated by a third party.

IPOR Interest Rate Swaps can be closed (similar to an American style option) by the owner at any time. The process of closing is as simple as clicking a "close" button and signing your transaction with your wallet. When a trader decides to close the position, they will be reimbursed the liquidation deposit charged when the derivative was opened.

Besides being closed by the owner, the IPOR Protocol allows the closing of the derivatives by the community given certain conditions:

- The derivative has reached its maturity-
- The derivative has lost all collateral
- The derivative has made 100% profit on collateral

At launch, the winnings and losings are capped at 2X or 0 as there is currently no simple way to enforce a margin top-up by the trader on the blockchain, resulting in an asymmetrical payoff risk against the pool if the contracts were allowed to exceed these limits.