# Quick Analysis of Hyperdrive Lending
This document lays out some of the analysis on the possible market dynamics I've been doing around the PT lending market which is designed as a short leveraging system to be built in combination with the hyperdrive AMM.
Some of the basic assumptions I used are:
* Interest rates are roughly efficient. All investments have both a payoff which I'll call $i_x$ for interest of x strategy and a risk of loss $r_x$ for risk of x strategy. To extend this logic both should be distributions but we treat them like scalars. Perfect information assumptions are highly doubious in crypto but we do assume that for all $i_x$ and $r_x$ that $i_x - r_x$ will converge to be close $r$ which is denoting a global market risk free return.
* Captial providers will choose the investment option x which has highest $i_x - r_x$ and will not choose strategies $i_x - r_x << r$ which is to say: people will choose to make more money and only very few people will deposit if the rates are better on average elsewhere.
* $r_x$ is the expected value of a probability distribution [with some bias as humans and human institutions tend to be loss avoidant]
* Generally in crypto $r_x$ comes from smart contract risk [incl oracle risk, bug risk, ect] and the more smart contract layers the more risk
## My understanding of the lending market proposal
Users should be able to deposit a crypto such as USDC and then that capital will be lent by the contracts into an approved strategy [eg gearbox]. The goal is fixed rate lending though I consider both fixed and varible options here. Borrowers obtain a debt demoninated in PT so that they can short PT market prices [eg are long corresponding interest rates], this is intended to have an upward pressure and market setting dynamic.
## On combined type pools
We work here with the assumptions of variable rate lending for simplicity but the analysis also applies to fixed rate lending. Given a basket of strategies $\{x, y, z \}$, they each have interest rates and risk profiles. You might pick an interest rate which is roughly $(i_x + i_y + i_z)/3 = i_a$ for a average rate, however this rate doesn't give a risk free return for captial providers which will approcah risk free rate $r$. The simple reason for this is that you lack a proportionality metric in utilization, if more of the funds are in a pool with higher risk the average then the risk free rate rate for captial providers is lower.
* Assume that a pool is 2/3 x 1/3 y and 1/3 y and that $r_x > r_y$ and $r_x > r_z$. Then the risk of loss is roughly $2/3 r_x + 1/3 r_y + 1/3 r_z = r_a$ but this is problematic as either $i_a - r_a < i_y - r_y$ or $i_a - r_a < i_y - r_y$. For an intuitive reason as to why, the average interest $i_a$ only has a 1/3 contribution from $i_r$ but the risk $r_a$ has a 2/3 contribution from it, so given the way averages work one of the other components must 'make up' for the differential. However this means no LP should be in the pool as the risk adjusted return is lower than one of the risk vectors.
The take away from this counter example is that an average rate setting system should be using a weighted average of its component rates. This way as the utilization of a high risk asset goes up the interest rate also goes up.
### Response time bugs
One implicit assumption of using an expected value risk and additivity in the previous section is that loss events happen instantly. However this is not true in DeFi. Rather only some events happen in that way and adjust the interest rates in real time. Consider a major hack to DAI or another stable which causes a lending market to become unbacked. The inability of the system to pay back it's debts may not be represented in the rates. Combined with the borrowing system for hyperdrive this implies that the risk rate is not and or but rather an and.
* Consider a protocol failure in yearn which represents major loss but the yearn multisig hasn't updated the onchain interest rate in price per share. A savy user Alice could borrow all of the assets from the market to short the yearn PT markets. The markets are 'uncollateralized' but strategy permissioning is effectively collateralization. Yearn PT hit 0 and then Alice keeps most of the collateral, buys back yearn PT and pays the debts leaving the lending market with a loss of almost all principal.
This means that the risk for the lender is not strictly confined to the assets which at any instant are deposited into a protocol but rather the risk of all protocols at all times. This implies that the rate for this market $i_a >> i_x + i_y + i_z$ as $r_a >> r_x + r_y + r_z$. However this is highly untenable as either shorts will be highly unprofitable or be very short. But if the leverage is depended on as a market setting dynamic having a negative carry means that the interest rate is distorted as the shorts must close.
A potential solution to this is that whenever new assets are added they are added with a utilization cap which is configured so that in a meltdown the pool is not fully wiped out. However this adds maintenance overhead and the risk of protocols can actually change over time, so would likely mean an active governance system to maintain lending markets.
### Perverse utilization incentives
Another potential mismatch of the mixed asset lending market to the hyperdrive system is how the rate setting mechanics affect the viability of trading.
First let's explore a bit how the rate setting dynamic happens in the the market. Like v1 the expected yield from the short is paid to the shorter [ie like ytc] because their debt is denominated in PT they can also close the short to profit. However besides some swing traders most of the market should be set by expected yield accrual, for an example why consider the extremal case where no variable rate is paid to the shorter.
* A user Alice is a net shorter and to give her a good trading opportunity we start the market at 0% interest. She shorts and is paying interest on a debt on 1 million so that the market moves to paying 5% interest. Her shorts now have a value of 50,000 [= 0.05*1000000] she pays an interest roughly that rate of 5% on 1 million PT debt, so if held to expiry of the PT then she will make 0. If she expects the PT to only go down that much she must close now, each interest tick create a small loss for her. Because she's setting the rate in the AMM if she closes the rate will be 0 again without other traders or at some midpoint assuming other traders exist. However all market participants know this dynamic should exist in a free market and so rationally must target lower than expected yield. This creates a chaotic market expectation which is really a game of when shorters should close not an expression of interest rates.
Given this the expectation is that the market midpoint price should be either set by 1x short PT sellers who are basically YTC w/o lending or by borrowers based on the differential between the expected variable payoff and the lending rates.
However the capped weighted average from the previous section bakes in problems when it is used to set rates based on variable interest. Namely it creates a distortion where the highest risk lending pool will have a borrow rate which is lower than the variable rate till the cap is hit. This makes borrowing a persistently good deal until fees plus interest are greater than the expected interest from the pool or until lending cap is hit. This will drive the utilization of the highest risk asset to 100% of cap and correspondingly the utilization of the low risk assets to 0 as they will have a rate which is averaged with the higher risk asset and so their borrow rates won't be able to pay the expected yield of the lower risk asset.
There is also a strong potential depending on fee model that the lending market will be at a persistent disadvantage to direct 1x YTC style PT sales by people who are long the expected yield. This is because lenders should expect a bonus on their rates for the added smart contract risk and charge fees over the expected interest rates. However direct 1x sales to the AMM do not have this additional risk and so the cost of capital for them is closer the the market expectation.
Some of the points from the previous section apply most strongly to having a variable rate pool who's rates track the underlying yield source rates, but still apply heavily to fixed rate lending models. We examine some details of fixed rate in the next section.
## Fixed Rate lending to PT AMM isomorphism
If we construct the lending market for the the PT to have fixed rate lending guaranteed at the time of creation then we still have a number of the properties from the previous section. Most important is that the way that interest rates are set for the protocol must allow there to be a market correlated risk free rate of return for the fixed rate lending. In addition there should ideally be caps if multi assets are used and some way of accounting for the tension in lending rates between multiple assets.
However there is an additional concern with the price setting behavior of the fixed rate lending system, each time the lender writes a fixed rate loan they have the potential for 'mark to market to loss where their borrower pays a rate less than the variable rate they could have earned over time. In a variable system the lenders are guaranteed that if rates go up they will not miss out on upside. However market makers are unlikely to get 'mark to market' gain as when the fixed rate is much greater than the variable the borrower is loosing money on the short and in many cases should close. Pricing models which track variable rate Alice should even 'refinace' and atomically buy back their pt, reborrow at reduced rates.
The primary question of fixed rate lending then is what corelation between fixed rates and variable rates should the lender apply? Price too low and they are likely more profitable if they directly deposit into the yield source, too high and they get no volume. This means ideally the fixed rate on offer should track variable rate. Or if using the multi source lending a basket of rates averaged by risk and utilization.
Tracking a historical basket of rates and pricing against this is the most simple model for pricing the fixed rate, but this creates problems because it doesn't respond to market information unless the lender is large enough to change the underlying interest rates. There are roughly two approaches to solve this, either a utlization curve where the more that is lent out the more difference between the lending and historical rate is; or indexing to a market price for PTs in the hyperdrive AMM. The first case has not been favored in previous discussions because it doesn't have a strong of a market dynamic, rather governance must set the system's responsiveness and may miss and so run out of lending or not lend enough out to maximize rates.
The approach of pricing lending to the AMM rate raises a more fundamental question. If the lending market is allowing users to get fixed rate positions in order to buy the expected yield [or take short term interest rate shorts], and it is pricing them on an AMM style curve/using the hyperdrive system to quote mid market rates, then in what way is this lending market different than a PT market maker? Consider that in order for the system to be capital efficient enough to attract LPs it must also be investing unlent funds, and any lent funds are effectively PT buys at a mid market AMM set rate. This makes the problem of how to set interest rates and the net exposure of the lending market be very close to having a PT AMM pool with asset delegation.
Why not simply roll the lending market into the AMM itself and create direct YT buy from the Hyperdrive AMM?
## Conclusion
Either variable or fixed rate version of the lending market create strong distortions whenever they have multi yield sources internally. Plus the only way I see to make them viable at all requires active governance maintenance. At the same time a fully fixed rate version of the lending market reduces in exposure and interest rate setting problem, to be very close to or identical to a PT market maker. For this reason my analysis of this problem is that instead of having a PT market maker the capital in the AMM should be used to create direct YT purchase markets.