# Lend • Borrow • Loop

Lending markets sit at the heart of DeFi. They allow depositors to earn yield on idle assets while enabling borrowers to unlock liquidity without selling their holdings. To understand how the system works, you only need a few simple concepts and general formulas.

{% hint style="info" %}
The concepts introduced here are the primitive foundations of DeFi lending mechanisms, providing a basic understanding for new users. However, modern protocols have made significant improvements and developed new advantageous approaches. Make sure you review each protocol's specific implementation.
{% endhint %}

***

### How does it works ?

## 1. Deposit&#x20;

When users deposit tokens (for example SOL or USDC), these tokens become part of a shared liquidity pool.

The protocol measures the size of this pool with:

<h4 align="center"><span class="math">\text{TVL} =  \text{TokensDeposited} \times \text{Price}</span></h4>

#### TVL = Total Value Locked&#x20;

***

### 2. Some of the Pool Is Borrowed

Other users can borrow tokens from this pool. So at any given moment:

* A portion of the pool is sitting unused
* A portion is borrowed by users

To track this, the protocol computes:

#### **Utilization Ratio**

<h3 align="center"><span class="math">U = \frac{\text{Borrowed}}{\text{Supplied}}</span></h3>

This number tells how “busy” the pool is.\
If only a small share is borrowed → low utilization.\
If almost everything is borrowed → high utilization.

This ratio is fundamental because it shows how much liquidity is available for withdrawals and how active the market is.

***

### 3. Deposits Become Collateral

When you deposit tokens, you can choose to **use them as collateral** to borrow other tokens.

To do this, the protocol first computes how much your collateral is worth:

#### **Collateral Value**

<h4 align="center"><span class="math">\text{CollateralValue} = \text{SuppliedAmount} \times \text{Price}</span></h4>

This is simply: “What is the USD value of everything I deposited?”

This collateral is locked and serves as a guarantee that you will repay your debt.

***

### 4. The Protocol Limits How Much You Can Borrow

You cannot borrow the full value of your collateral.\
Every asset has a safety percentage called **LTV** (Loan-to-Value).\
It ensures that if your collateral falls in price, the protocol remains safe.

Your maximum borrowing power is:

#### **Maximum Borrow Value**

<p align="center"><span class="math">\text{MaxBorrow} = \text{CollateralValue} \times \text{LTV}</span></p>

This is the highest borrow value you are allowed to reach.

So if you deposit 100$ of asset A, you can borrow 75% x 100$ = 75$ of asset B.

***

### 5. Your Borrowing Position Also Has a Value

If you take a loan, the protocol also tracks the value of what you borrowed:

#### **Borrow Value**

$$
\text{BorrowValue} = \text{BorrowedAmount} \times \text{Price}
$$

Now the system knows:

* how much value you have deposited
* how much value you have borrowed

The relationship between these two decides how safe your position is.

***

### 6. Safety Is Measured With the Health Factor

To protect the protocol, each asset has a **liquidation threshold** (slightly higher than the LTV).\
It reflects the value of collateral that can be safely counted in worst-case conditions.

The protocol computes:

#### **Liquidation Value**

<h4 align="center"><span class="math">\text{LiquidationValue} = \text{CollateralAmount} \times \text{Price}\times \text{LT}</span></h4>

Then your overall safety is expressed through one simple number:

#### **Health Factor**

<h3 align="center"><span class="math">HF = \frac{\text{LiquidationValue}}{\text{BorrowValue}}</span></h3>

This number is the heart of the system.

* **HF > 1** → your position is safe
* **HF = 1** → you are exactly on the edge
* **HF < 1** → your position can be liquidated

This is how the protocol ensures that loans are always backed by enough collateral.

#### Looping / Recursive Lending

Looping is the practice of borrowing an asset, swapping it, and depositing it back as collateral to borrow even more:

1. Supply asset A.
2. Borrow asset B against asset A.
3. Swap B back to A.
4. Supply the swapped A as additional collateral.
5. Repeat until you reach your risk tolerance.

Ex with LTV = 80% :&#x20;

1. Borrow  100 $USDC against 100$ worth of $SOL
2. Swap your  $USDC for 80 $SOL
3. Add it back to the collateral, you now have 180$ worth of $SOL, that is a 1,8x leverage.
4. Repeat.

Each type you loop, you increase your leverage a little bit less than the previous round, this manual process can become tedious, that is why DeFi protocols have introduced automated looping using flash loans.

#### Risk Controls

* **Liquidation Threshold (LT):** If your borrow ratio exceeds LT, liquidators can repay your debt by seizing collateral.
* **Health Factor:** `HF = (Collateral Value × LT) / Borrow Value`. Keep HF comfortably above 1 to avoid liquidation.

### How to use lending loops in Stazys

* Grow base yield by looping staking derivatives (LSTs) in lending markets.
* Pair lending protocols with automated swaps to keep loops efficient.
* Use signal-driven logic to adjust loops when utilization, APY, or collateral prices change.

With some creativity, this let users unlock out-of-the-box ideas for innovative strategies.

#### Next Steps

* Dive into Kamino Markets for an automated lending protocol with rich risk analytics.
* Explore Jupiter Lend to see how unified liquidity and high LTV vaults enable flexible lending opportunities


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://stazys.gitbook.io/stazys-docs/stazys-defi-guide/lend-borrow-loop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
