> For the complete documentation index, see [llms.txt](https://contango-2.gitbook.io/exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://contango-2.gitbook.io/exchange/protocol/borrowing-and-lending.md).

# Borrowing and lending

### Fixed rate markets

Each time the protocol opens an expirable position for a user, borrowing and lending at a [fixed rate](/exchange/resources/glossary.md#fixed-rate-market) occur on other DeFi protocols. At a high level:

* lending at a fixed rate is equivalent to buying a discounted zero-coupon bond
* borrowing at a fixed rate is equivalent to selling a discounted zero-coupon bond.

The maturity of the expirable needs to match the maturity of the zero-coupon bonds.

Contango uses different protocols to borrow and lend at a fixed rate. In this section, you would find more information about our integration with:

* [Yield](https://yieldprotocol.com/)
* [Notional](https://notional.finance/)&#x20;

### Flash swaps

Contango uses the concept of [flash swaps](/exchange/resources/glossary.md#flash-swap) to make the protocol capital efficient. Let's say a trader wants to buy 1 ETH with 100 DAI. Without using flash swaps the trader would need to first give DAI before receiving ETH. With flash swaps the trader could get 1 ETH first as long as the 100 DAI are given back in the same block. If that's not the case the transaction is reversed. This allows the trader, or a protocol such as Contango, to perform some actions between receiving the 1 ETH, at the start of the transaction, and giving 100 DAI at the end of the transaction.

#### Position opening

Let's start by taking the example in the [position opening](/exchange/protocol/protocol-pricing/position-opening.md) section, where a trader buys 1 expirable at $$100.59 : DAI$$with $$S\_{L}=100.10 : DAI$$. The protocol owes a debt $$D=50.59 : DAI$$. Let's say the borrowing requires a minimum collaterization ratio (CR) of 140% margin, i.e. the equivalent of $$50.59\*140%=70.83 :DAI$$. The trader has only posted $$50 : DAI$$as margin, i.e. $$CR\_{borrow}={50}/{50.59}=98.83 %$$, there is clearly not enough money to do the borrowing with over-collaterisation.

Using flash swaps on the spot market, e.g. on Uniswap, the protocol is now able to meet the collaterisation ratio requirement by:

1. first getting the $$ETH$$ to be lent
2. lending $$ETH$$ by buying its zero-coupon version $$zcETH$$, worth $$0.9929 \*99.90 = 99.19 :DAI$$&#x20;
3. using this zero-coupon as margin to borrow the required fund. The collaterisation ratio for borrowing would be $$CR\_{borrow}={99.19}/{50.59}=196.07 %$$ which is above the required 140%.
4. Swap the borrowed $$zcDAI$$ for $$DAI$$.&#x20;
5. use the borrowed $$DAI$$ plus margin to pay for the initial $$0.9929 : ETH$$.

![Flashswap steps to open a long position](/files/yBZp8oaCH0662k0hyuii)

#### Position closing

Contango closes a position by reverting the above steps. In the long example in the [position closing](/exchange/protocol/protocol-pricing/position-closing.md) section, the protocol follows these steps:​

1. &#x20; $$0.9924 :ETH$$ is repaid back from lending and swapped for $$99.14 :DAI$$.
2. $$DAI$$ is exchanged for its zero-coupon bond version, $$zcDAI$$.
3. $$zcDAI$$ is then used to reimburse the debt and retrieve $$zcETH$$ which is worth $$49.41 :DAI$$.
4. The margin is swapped for $$ETH$$.
5. $$ETH$$ is given back to close the flashswap.

![Flashswap steps to close a long position](/files/lZiR2wm0SsKsjGdcC0xu)
