---
# System prepended metadata

title: Hyperdrive Borrow

---

# Hyperdrive Borrow 🔒

## Preface
Fixed borrowing for lending markets is one of the leading applications for Hyperdrive. This document intends to formalize this application and come to a better understanding of the mechanism and risks.


## What is fixed borrowing?
Borrowing in DeFi involves creating a CDP (collateralized debt position) with an interest rate owed by a borrower over time to pay a supplier. 

Most loans in DeFi have a variable interest rate, where borrowers take on variable debt and suppliers earn variable interest, both of which are dynamic and difficult to predict.

Fixed borrowing simply describes taking out a fixed-rate loan, where the interest rate owed to the supplier is static and the amount of interest owed over the duration of the loan is predictable.

## Mechanism
Hyperdrive wraps yield sources to create yield markets, giving users access to fixed and variable yield positions. These yield markets allow users to hedge their variable debt positions and turn them into fixed borrowing positions.

There are two sides to every lending market: the suppliers and the borrowers. Suppliers deposit assets and earn the interest paid by borrowers, minus fees. Hyperdrive will wrap the supply side of this market, creating fixed and variable yield supply positions.

So if a borrower has a variable debt position, they can use Hyperdrive to transform it to a fixed debt position by doing the following:

- Deposit collateral into a variable rate lending market
- Take out a loan as a variable debt position
- Purchase a short in Hyperdrive to hedge the variable interest they’ll owe on the loan. (The short earns them a variable interest to match the variable interest they’ll eventually owe to settle their debt)
- When ready to pay the debt, sell the short back to Hyperdrive to earn the yield to pay it off

In this scenario, effectively all they owe is the short’s fixed payment upfront to settle a loan debt which otherwise would require an unpredictable payment at the time of close. This upfront cost can be interpreted as the fixed rate. 

When a user purchases a short in Hyperdrive, they pay an upfront cost, also known as the max loss, in exchange for variable yield exposure. At the end of some predefined time length, in a balanced market, the amount of interest accrued from the loan and the Hyperdrive short is the same. Thus the only cost to the user was the upfront cost for the variable yield exposure. 

Let's run through an example:

The market is currently at a 5% variable APY.
- Alice takes a loan on Aave of 100 USDC at 5% variable APY.
- The Hyperdrive market is priced at 5%.
- Alice needs to hedge 100 USDC variable APY.
- Alice shorts 100 bonds for 5 USDC.
- Alice now earns variable yield for 100 USDC.
- After the short expiry, Alice closes her short in exchange for the amount of variable interest accrued on her loan.


## Interest Rates
Let's delv into a primer on how interest rates work in popular lending protocols. Remember, there are two sides to the market.

Interest rates in lending protocols are calculated using a formula. This formula varies slightly by protocol.

![Screenshot 2024-02-21 at 3.46.07 PM](https://hackmd.io/_uploads/B1IGegVha.png)

The borrow rate (red) is a linear piecewise function, and the x-axis represents utilization. This formula is used to manage liquidity risk and optimise utilization in the lending market. Rates rise slightly as utilization increases. When the current utilization exceeds the target, in this case $90\%$ the rate increases faster to attract more suppliers. 

Let's define some initial constants:

$U = 0.90$, target utilization
$k = 4$, constant for curve steepness
$u_t$ = utilization at a specific time

The borrow rate can then be described as.

$R_B(u_t) = \left\{ \begin{array}{cl}
(1-\frac{1}{k}) \cdot \frac{u_t - U}{U} + 1 & : \ u_t \leq U \\
(k - 1) \cdot \frac{u_t - U}{1 - U} + 1 & : \ u_t > U
\end{array} \right.$

Let's evaluate the supply function (green). The supply rate is proportional to the borrow rate with one difference: it's multiplied by the utilization rate. This means a spread will always exist in this interest rate model. In the graph, you can see the supply function is not linear like the borrow function; this is due to the utilization modifier. 

$R_S(u_t) = R_{B}(u_t)\cdot u_t$

This spread poses a significant problem when trying to achieve a true *fixed rate* using Hyperdrive since interest generate from the supply side would not be enough to cover borrowing cost. Let's define a new function called the gap function (blue). This function represents the interest rate spread between borrow and supply rates at a given uitlization.

$G(u_t) = R_{B} - R_{S}$
![image](https://hackmd.io/_uploads/Sk0yJuq36.png)

Ultimately the true borrowing cost would be the cost to open a short and the remaining uncovered interest.

## Proposed Solution

The hedged position works by offsetting the borrow-side costs with the supply-side earnings. However, the borrow and supply curves don't share the same slope, so there must be a point where the gap between the two rates is widest, that is, there must be a specific utilization rate that maximizes the hedged position's total cost. Let's visualize both rates and the gap between them in an amplified graph:

![image](https://hackmd.io/_uploads/r1cWEO5hp.png)

The gap between the borrow and supply rates can be defined as the borrow rate minus the supply rate:
$$G(x) = R_B(x) - R_S(x)$$

The gap is maximized when its derivative is 0, which gives us the following equations:

$G'(x) = R'_B(x) - R'_S(x)$

$G'(x) = 0$

We find the derivatives of the supply and borrow rates:

$R'_B(x) = \dfrac{k - 1}{k \cdot U}$

$R'_S(x) = \dfrac{2 \cdot (k - 1) \cdot x + U}{k \cdot U}$

Which gives us:

$G'(x) = \dfrac{k - 1}{k \cdot U} - \dfrac{2 \cdot (k - 1) \cdot x + U}{k \cdot U} = 0$

Let's simplify:

$x = \dfrac{k - 1 - U}{2 \cdot (k - 1)}$

We can see that the hedged position's worst case scenario is calculated by two properties: the slope and the target utilization rate. If we plug in the constants from the earlier example we can find our worst-case rate, which can be advertised as a fixed rate:

$U = 0.90$, target utilization
$k = 4$, constant for curve steepness

$x_0 = \dfrac{4 - 1 - 0.90}{2 \cdot (4 - 1)} = 0.35 = 35\%$

We can then define the hedged position's fixed rate (i.e., its worst-case rate) as follows:

$R_{max}(u_t) = R_S(u_t) + G(x_0)$



## Market Analysis
It's important to highlight that certain markets and protocols favor fixed-rate borrowing over others. There are a couple of properties to look for in these lending markets that will significantly decrease risk for fixed-rate borrowers:

- Active market
    - The market should be active, and market opportunities should be capitalized on in a reasonable amount of time.


- High target utilization rates:
  - When a market has a high target utilization rate, the borrow-supply rate spread would be near its lowest if the market is efficient, making it cheaper to hedge properly.
  - Examples include the Aave USDC market.

- Isolated lending pools:
  - Isolated lending protocols such as MorphoBlue provide higher utilization rates and smaller spreads than a pooled lending market.
  - Pooled markets can have very imbalanced pools due to incongruent demand.
  - For example, the stETH market on Aave. The borrow-supply rate spread is high because many users deposit stETH as collateral and then borrow another asset. The demand to borrow stETH is low while the supplied amount is high. In an isolated lending market, there is only one asset that can be supplied and borrowed.

- Avoid new markets
    - New markets should be avoided so the above properties can be evaluated.


## Open Questions
- How should the risk involved be accurately portrayed in the brand of this product?
- Do we want to include any fees in this product?
    - If so, do fees accrue to DELV or a DAO?


## Resources
- https://www.desmos.com/calculator/kiectcgwlx
- https://www.desmos.com/calculator/osm9npc3bc
- https://docs.google.com/spreadsheets/d/1w_tn1QQeDxUEBwg2u5wsA6XWcEj6OKxgNLVt9AiL90U/edit#gid=778991337


## OLD - overhedging

Given that Hyperdrive will wrap the supply side of this market, this spread will need to be included in our calculation in how many shorts a user needs to properly hedge a variable debt position.


Let's define a new function called the multiplier function. This function, $M$, is the amount that the supply function will need to be multiplied by to equal the borrow rate at a specific utilization. 

$M(u_t) = \frac{R_B(u_t)}{R_S(u_t)}$

<img src="https://hackmd.io/_uploads/rJYv14rna.png" style="height:400px;width:300px" />

- An asymtotic function similiar to $\frac{1}{x}$
- Approaches $\infty$ as utilization decreases


This function reveals some interesting properties. The interest rate spread is proportionally different across utilization rates. This spread widens as utilization approaches 0. This makes sense intuitively given that the only revenue in this system is the interest paid by borrowers, and not all supplied assets are being utilized.

This poses a problem for achieving a true fixed-rate debt position using Hyperdrive, particularly in the situation where the market utilization falls from the point at which the borrower hedged their position.

Luckily, market dynamics are on our side. Each lending market defines a target utilization depending on the risk classification of the tokens involved. For any actively liquid market, we can reasonably assume that the utilization will oscillate around the target utilization.


- If utilization falls, rates fall, leading to a market opportunity for borrowers.
- If utilization rises, rates rise, leading to market opportunities for suppliers.

In conclusion, it's still possible to offer fixed-rate debt positions using Hyperdrive, although a more formal definition would be a **hedge**. Providing transparent tools and data for fixed-rate borrowers would ensure that in the event a short accrues interest less than the variable debt loan, the borrower is aware and can take action.













