# Welcome to AMMplify

Ammplify is an all-in-one platform for AMM yield farming.&#x20;

We **aggregate**, **analyze**, and **amplify** yields for liquidity provisioning on AMMs across the whole ecosystem. Currently we're only available on Monad.

## Aggregate

Browse top yield opportunities for a variety of AMM protocols. For now we just support Capricorn and UniswapV3 but more protocols are continually being added.

## Analyze

Nothing is more important than estimate potential earnings accurately. Unfortunately most protocols simply track **historical** fees. We instead use modern options modeling techniques to **project** fee earnings and we make evaluating Impermanent Loss a breeze.

## Amplify

We wrap all your AMM deposits with an amplification contract that re-deposits back into the AMM of your choice, but does so in pieces. By doing it in pieces, we're able to automatically auto-compound your concentrated positions for free and we can enable additional rehypothecation yields.&#x20;


# The Mission

We believe that DeFi is using liquidity wrong. It is shocking to us that in the most open and composable financial system in the world, protocols are still building isolated pools of liquidity. It is shocking that money markets like AAVE and stables like Maker don't power the majority of perp protocols and that Curve doesn't power Y2K's depeg insurance. As a result, it feels like we don't have enough liquidity in DeFi to power all the new innovations of tomorrow when in reality, we'd have plenty if we'd just use it more intelligently.

So if these protocols won't open up access to their liquidity, we'll do it for them by being the liquidity brokers of DeFi. Sourcing liquidity and building great consumer experiences are two separate problems. To us, there's no reason someone who can build a great product has to be saddled with maintaining a liquidity pool and no reason liquidity must only earn from one product. Hyperplex aims to build a future where both sides meet efficiently and DeFi can forge ahead without the constraints of liquidity.


# User Guide

Start by visiting [ammplify.xyz](https://ammplify.xyz)! Browse pools and click into a pool to get to the deposit page:

<figure><img src="/files/ZFN7WbnvSNYMPN4QvN62" alt=""><figcaption></figcaption></figure>

After connecting your wallet, you'll be able to deposit into your AMM of choice with additional yield amplifications and more position performance tracking.


# Risks

Using Ammplify to boost yields come with just two drawback:

1. Smart contract risk. As with any defi protocol, there carries some smart contract risk. We've been thoroughly audited with a Sherlock contest and we continue with audits and bounties. Furthermore there is some degree of centralization to safeguard the protocol if needed.
2. Withdrawal queues. If the liquidity in a pool gets very thin, withdrawals may have to face a minor delay (similar to unstaking). This is because some strategies take some time to unwind. Currently, there is no withdrawal queue scenario.

We were careful to put strong safety guarantees into the smart contract itself so user can feel confident when boosting their earnings.


# Analysis Charts

When analyzing yield opportunities, Ammplify offers some useful charts.

<figure><img src="/files/OyZKxYz3kjOnLKaWH1O5" alt=""><figcaption></figcaption></figure>

We have the classic liquidity charge, but overlayed is where the simulations' fee earnings ended up.

<figure><img src="/files/c5n0dNFZ1eIo49JYdFgE" alt=""><figcaption></figcaption></figure>

We simulate multiple scnearios and we draw the median fee earning curve for your position. This spans your desired time range.

<figure><img src="/files/UfIkat48uZOTfDSE1CiX" alt=""><figcaption></figcaption></figure>

The IL Graph. Instead of using an IL calculator, we show you the IL for the entire range of ending prices. To be specific, we actually show the PnL change induced by IL compared (as a percent change).

<figure><img src="/files/vyaa5ogmkQnQ3XzJjm8m" alt=""><figcaption></figcaption></figure>

We also show the distribution of the simulated IL on the side. So you know what the IL likelihood is. It is scaled for your date range.&#x20;


# Congestion Pricing

Congestion pricing is our take on dynamic fee pricing. But unlike other attempts we don't prescribe what that fee should be. Our main focus is to make sure that users earn more on Hyperplex than they would on their base AMM, and to stretch that benefit as much as possible.

As most experienced AMM users know, Uniswap's fixed swap fee is not optimal. There's been lots of suggested alternatives but formula based approaches are always going to lag the market. Instead we're built around reserved liquidity.

## Reserved Liquidity

We allow other protocols to reserve liquidity so they can swap against it in the future. This means they pay a borrow rate to reserve liquidity. The liquidity gets removed from the AMM, but when the price moves through that liquidity's range the borrower is forced to swap against it and pays the same swap fees. From a Hyperplex user's perspective, there is no difference. The liquidity behaves the exact same way, they earn the same swap fee, experience the same IL. And because this reserving behavior is done peer to pool, unless all the liquidity in the pool for that range is borrowed, each user can still withdraw freely. The only difference now is that our AMM depositors also earn an extra borrow fee from the reservations which gets split pro-rata among everyone who's deposited liquidity into the borrowed range.

### Why would someone reserve liquidity?

Some protocols like derivative protocols offer complicated products to their users. They need assets to back those products and the ability to trade those assets to perfectly hedge the exposure of the product they sold. So by reserving liquidity on Hyperplex, they are guaranteeing themselves that they have the swap liquidity necessary to exit and enter positions as needed to synthetically replicate the derivative they're selling.&#x20;

As a result, they save money because they don't need to bootstrap and manage their own liquidity pool. And a portion of those savings gets passed onto our re-LP's through that reservation fee. In then end, both sides come out better for it.

### Risks?

Although with congestion pricing the AMM liquidity is effectively being used to underwrite derivative protocols, none of the deposited tokens are actually sent to those derivative protocols. Those protocols are just reserving the right to execute private swaps. Our depositors don't face any of the risks of the reserving protocol. Each reserving protocol puts down collateral to pay for their forced swaps and when they run out of collateral the reserved liquidity is moved backed to the base AMM.&#x20;

## Pricing

The reason this is called congestion pricing is simple. The more liquidity that gets reserved, the higher the borrow fee is. At really high borrow rates (like when 90% of the pool is borrowed out), the rate goes so high we start liquidating the borrowers so that our users can withdraw their funds. At the end of the day we make sure our users face as little illiquidity risk as possible.


# Auto-Compounding Old

We're one of the only auto-compounders for concentrated LP position&#x73;**.** Some protocols misrepresent auto-compounding and over promise on its benefits so let's dive in and demystify what **actually** happens with auto-compounding, when you should use it, and what makes ours so special.

## The Basics

Auto-compounding means taking your fees and reinvesting it back into your LP position. The benefit is your subsequent fee earnings are great because your LP position grew. **But** while your original position does not change, just know that because your fees have become liquidity they'll also experience IL and the fluctuations in your position's value will also grow.&#x20;

<details>

<summary>When should I auto-compound?</summary>

An easy rule of thumb is to only auto-compound on low IL pairs such as stables pairs or highly correlated pairs like BTC/ETH. A more technical rule is to compare your estimated fee APY to your estimated IL percent. If the following inequality is true, then it's generally good to auto-compound.

$$APY > \frac{IL}{1-IL}$$

For example, if you're losing \~20% to IL over the course of a year, your APY should be more than 25% to make compounding worth it. Here's a chart to make that lookup easier. Above the line you should auto-compound, below you shouldn't.

![](/files/neWn21WkiAgiuA9crSZ9)

If you're LPing into pools with greater than 35% IL, you'd really need some crazy yields to make it worth it. So crazy it'd make the chart too hard to read so I left them off.

The truly correct technical answer is actually really complicated. It requires you to model when impermanent loss occurs since it's a stochastic process and you have account for ergodicity (a fancy word for the fact that this is an iteratively multiplicative process), fun challenges if you're interested in math, not so fun if you're just trying to invest. So for now I'll leave it as this: compound when IL is low.

</details>

## Predatory Auto-Compounders (Fees)

Protocol that charge you a fee every time they compound is **extremely predatory** and usually make auto-compounding not worth it. By compounding you still experience increased IL but now your earnings are reduced. Even if the protocol's take is small, like 1 or 2 percent of the collected fees per compound, because of the multiplicative affect of compounding this can actually make a positively earning position lose money over time.

For example, in [#when-should-i-auto-compound](#when-should-i-auto-compound "mention") I give an example that you need to earn 25% in fee APY to offset a 20% IL loss to make compounding better than not compounding. But if you're paying 2% of your fees per compound, now you have to earn 31.8% in fees to offset the same 20% in IL. You have to earn 27.2% more to make this make sense! LPing is hard enough, let's not handicap ourselves even further.

## Our Auto-Compounder (Free)

Fortunately our auto-compounder doesn't charge any fees and doesn't eat into your profits. The way ours works is that every time someone deposits or withdraws an LP position on our platform, all positions in the overlapping ranges are compounded in a gas efficient way. Under the hood since all positions are bucketed into group ranges, any single person operating on a group helps compound the entire group. This means the more people that use Hyperplex, the more it compounds and the better it is for everyone.

### Concentrated LPs

At the point of writing this, Hyperplex is one of the few auto-compounders out there for concentrated positions and the only one that does it for free. Auto-compounding concentrated positions is usually really difficult because each position is non-fungible and must be compounded one by one. Our internal bucketing system solves this problem and can compound millions of position just as cheaply as compounding one position.

## Unconcentrated LPs

Unconcentrated LP positions are usually automatically compounded by the base V2 AMM. We put full-range positions into concentrated AMMs (but still over the full price range) because concentrated AMMs get more swap volume and earn more fees, but as a result the base AMM no longer auto-compounds since it can't. So Hyperplex does it instead  and of course this is also free.

But remember that sometimes its more profitable not to auto-compound (see the equation in [#when-should-i-auto-compound](#when-should-i-auto-compound "mention")). With your usual basic full-range AMM you no choice but to auto-compound, with Hyperplex now you can at least choose.


# Re-LP Features

A summary of our current features

Here's a summary of our current features. Plenty more are coming soon!

## Yield Boosts

* **Rehypothecation**: Almost all of the liquidity in AMMs are not active and are just waiting to be used by a swap. So we simply move those idle tokens into other yields in the meantime helping you earn an added IL-free yield.
* **Bribes**: There were lots of V2 bribing platforms in the past but there are none for V3. We've solved the distribution problem allowing protocols to incentive liquidity for particular ranges (i.e. pegs or price floors).&#x20;
* **LVR Capture**: You don't always want to market make for every swap. Recent research into AMMs have shown that mimicking a swap after-the-fact can sometimes be more profitable. This is called LVR and we do exactly that to capture extra earnings.
* **Auto-Compounding**: "Compound interest is the eighth wonder of the world" - Albert Einstein. We continually reinvesting your earnings back into your position, we create a multiplicative effect on your earnings.
* **Reserve Pricing**: Some protocols want to guarantee themselves the ability to swap with reduced slippage. They can do this by reserving some of the pools liquidity for themselves to use. These reserves have to pay the base AMM's fee rate plus a bonus reservation fee which ultimately goes back to our users.&#x20;

## Safety Measures

* **Depeg Insurance:** If one of the two tokens in your LP pair catastrophically fails due to an exploit or a de-peg, your entire position would go to nearly zero on a regular AMM. This is by design because AMM positions are always market making. We constantly monitor every pool we wrap and hold far out-of-the-money liquidity in reserve to avoid precisely that scenario. This way we can salvage your position.


# Table of Contents

Here are all the ways you can boost your LP position.\
You get to pick and choose just the features you want.

Some are available now, while others are coming soon :relaxed:

<table><thead><tr><th width="181">Feature Name</th><th width="108">Choices</th><th width="177">Details</th><th width="146">Risks</th><th>Rewards</th></tr></thead><tbody><tr><td><a href="/pages/agdagPQuEZ58rRB8IcKk">Auto-Compounding</a></td><td>None</td><td>Free compounding for V3 positions.</td><td>Impermanent Loss</td><td>Compounded yields</td></tr><tr><td><a href="/pages/HvLLv3p1wScP2l7LyACb">Rehypothecation</a></td><td>Yield Source</td><td>Put idle tokens into other yield sources</td><td>Yield source risks</td><td>Extra yield</td></tr><tr><td><a href="/pages/sxBK5LZtAZPUa0YnLy0z">Congestion Pricing</a></td><td>Borrowers</td><td>Bonus yield from redirecting liq.</td><td>Smart contract &#x26; minor illiquidity risk</td><td>Extra Yield</td></tr><tr><td>IL Hedging</td><td>Max IL</td><td>Easy hedge to limit IL.</td><td>Borrow Costs</td><td>Reduced IL</td></tr><tr><td>Floor Hedge</td><td>Floor Value</td><td>Guarantee a floor value.</td><td>Borrow Costs</td><td>Floor Value</td></tr><tr><td>Delta Adjustment</td><td>Bull, Bear or Neutral</td><td>Be Delta-Neutral or add a short bias.</td><td>Borrow Costs</td><td>Reduced Losses</td></tr><tr><td>Liq-Free Leverage</td><td>Leverage</td><td>Leverage without liquidations. </td><td>Borrow Costs</td><td>Up to 100x Leverage</td></tr><tr><td>Fixed Yield</td><td>None</td><td>Swap your variable yield for a fixed value.</td><td>Rate Swap</td><td>Guaranteed Yield</td></tr></tbody></table>


# Rehypothecation

Rehypothecation is a big word for a simple concept. Because AMMs only use a single tick to market make at any given moment, most of the liquidity in an AMM is sitting **idle, waiting to be used**. We simply move those tokens to other low-risk yields sources to earn while they're idle, and move them back when they're needed by the AMM.

We provide a growing list of available rehypothecation protocols and you can choose which one you'd like. Some examples would be AAVE, Lido, Compound, EigenLayer, etc. After TGE, our token stakers will be able to decide that list.

<figure><img src="/files/3zVhRBls7qEGPP3k7uxg" alt=""><figcaption></figcaption></figure>

Users can choose as many or as few rehypothecation vaults as they want. If they choose multiple, we'll split the available tokens evenly between all applicable vaults.


# Risks

There are 2 types of risks when using Hyperplex, smart contract risk and illiquidity risk.

## Smart Contract Risk

When doing anything in DeFi, there is always the risk of a bug in the protocol. The minimize this we go through independent audits, commercial audits, white-hat competitions, live monitoring, and more. All of those steps go into security Hyperplex, but I can't the say same for our rehypothecation vaults. We will generally choose the safest options for rehypothecation, but if you choose a certain protocol to rehypothecate into just know that you are also assuming their smart contract risk. For example if you want to use Hyperplex to wrap a Uniswap position and rehypothecate into AAVE, you have Hyperplex, Uniswap, and AAVE's smart contract risk.

## Illiquidity Risk

Illiquidity is a term for when you want to withdraw a position but can't. For example, if you're a lender on AAVE but the entire pool is borrowed out you won't be able to withdraw until some borrow positions are closed or liquidated. In the meantime, AAVE will pay you an enormous lending APY.

The same is true for Hyperplex. If you use rehypothecation and the rehypothecation protocol (like AAVE) like some illiquidity risk, you would also not be able to withdraw until their illiquidity is resolved (which is typically very fast). If you use Congestion Pricing then if a tick in your liquidity range is entirely borrowed out, you can withdraw the rest of your range but you will have to wait for that tick. And again, your yield will skyrocket during that time to compensate. We aim to minimize illiquidity to a few minutes if it ever occurs.

If you don't use Congestion Pricing or Rehypothecations with illiquidity, then you don't have to worry about this risk.


# Yield Amplification

The first and easiest way to improve profits is simply earning more.\
Our amplifications help you do that without changing your liquidity range, your impermanent loss (IL), your AMM, or your liquidity distribution. Plus, you still earn all the AMM swap fees you normally would.

Right now, the two AMM amplifications we offer are:

1. **Bayesian Auto-Compounding**: Compounding dramatically improves yields, but sadly CLAMMs (concentrated liquidity AMMs) don't have compounding built in. Fortunately we have an intelligent auto-compounder that only compounds into profitable ticks and compared to competitors we're exponentially cheaper and more efficient. This dramatically improves yields and the only risk introduced is that your compounded fees will experience IL (which is true of all compounders), but your original position is completely unchanged.
2. **Pooled Liquidity Lending**: In the past, people have experimented with lending LPs for extra yield. They would earn both AMM swap fees as well as lending fees which is great, but the problem is that if your position was lent out, you wouldn't be able to close it. So Fluid got around this by making everyone use the same LP position, so lent positions were interchangeable.  Ammplify has the best of both worlds. We're able to pool together positions of all different ranges and still lend out interchangeable pieces of liquidity meaning anyone can use their own custom range while still staying liquid.

To start earning more immediately, users simply come to Ammplify, choose from their existing LPs (or make a new one!), and apply the amplifications they'd like.

## Predictable Yields

Besides extra earnings,  we also provide better modeling for risks and earnings.&#x20;

When it comes to Impermanent Loss risk, just using a IL calculator is not enough. Instead, we use resampling techniques to model future price movements (which you can adjust according to your price targets) so you can estimate IL and fee earnings from a distribution of prices at the same time.

This way users can estimate how much is a normal day to day swing in position value, and how long it'll take for cumulative earnings to overcome that volatility. We're making Liquidity Providing a conscious decision made with conviction, rather than a hope that fees are sufficiently high.


# Bayesian Auto-Compounding

We're one of the only auto-compounders for concentrated LP position&#x73;**.** Some protocols misrepresent auto-compounding and over promise on its benefits so let's dive in and demystify what **actually** happens with auto-compounding, when you should use it, and what makes ours so special.

## The Basics

Auto-compounding means taking your fees and reinvesting it back into your LP position. The benefit is your subsequent fee earnings are greater because your LP position grew. **But** while your original position does not change, just know that because your fees have become liquidity they'll also experience IL now.

Most auto-compounders work by withdrawing fees for a single position, and reinvesting the liquidity. This happens one by one and as a result protocols have to charge high fees to incentivize people to compound each position individually. Also, note that when they reinvest the fees, they reinvest it over the entire liquidity range.

## Bayesian

The first big upgrade to auto-compounding that we do comes from realizing that not all ticks in the liquidity range are useful. We should instead put our reinvested fees into the most useful pieces of liquidity, and if we had to guess which price ticks will earn the most going forward the best guess is the price tick that just earned fees! This is a bayesian approach to distributing liquidity and dramatically improves the yield earnings and capital efficiency of auto-compounded liquidity.

## Pooled liquidity

Under the hood, we're actually able to combine millions of positions into fungible pieces of liquidity and as a result, this means when we compound concentrated liquidity, we can actually compound all overlapping position in that liquidity range in a single call. So every time someone uses our protocol, they actually compound everyone else's position in their range without any additional gas cost! This means everyone gets compounded more frequently and more cost-effectively than they would on other platforms. Plus, there's no need to charge high fees for compounding. This also means that the more people who use the protocol, the more efficient it becomes.


# Rehypothecation

Liquidity providing positions will never have their full range be utilized. **Automatic rebalancing** is one approach to deal with this problem. It concentrates a position and shifts it around according to an oracle. This is a very reasonable approach! However it's a lot of work and experiences more IL.

Our approach is with rehypothecation, where any liquidity not used by a swap can be used for other yield purposes. This way all liquidity is "active". The tokens are often deposited into safe vaults for a passive yield. But the unique part of an AMM is IL, and IL underwriting is super valuable. Our type of rehypothecation allows "Takers" to make a bet. That they can sell IL from parts of the liquidity curve for more than what it would earn in swap fees. The tokens never leave the contract so the funds are always safe. The Takers just go out and do things like sell options, perps, and structured products to earn bonus yield. More than the base AMM's swap yield is guaranteed to be passed back to the deposits.


# AMM Basics

AMMs are one of the most popular ways to earn yield in DeFi. AMM stands for Automated Market Makers which are smart contracts users can deposit a pair of tokens into to add liquidity to a decentralized exchange. Traders then trade against this liquidity and in return they pay swap fees on each trade to those who have deposited liquidity.&#x20;

There are two types of deposits you can make on AMMs, unconcentrated positions (also known as full-range positions) or concentrated positions. Both of these are referred to as Liquidity Providing positions or LP positions for short or simply LPs.

## Unconcentrated/Full-Range LPs

This type of deposit spreads out your deposited tokens evenly across the entire price range. This means you're willing to swap the same value of tokens at 5 dollars as you are at 500 dollars. This means no matter where the price is, you'll earn fees. This type of position is usually taken when you don't know what the price of a token should be and want to reduce your risk. We'll discuss risk further on, but for now know that this type of position usually earns less but is less risky.

## Concentrated LPs

To make this deposit, you must first choose a range of prices. For example, if you're liquidity providing (LPing) for ETH/USDC, you might say the price of ETH won't go below 2000 USDC but won't go above 5000 USDC so you deposit liquidity just for that range. If you're right, it means you didn't waste any token deposits on prices below 2000 and above 5000. Your tokens were more efficient and you'll earn more as a result. But on the downside, if you're wrong you'll face more risk and lose more than the unconcentrated position. Most liquidity is concentrated these days. The more narrow your price range, the more risk you face. The wider your range, the less risky it is.

## Risk

The value of your deposit will decrease as the price moves, this is referred to as Impermanent Loss. If the price returns to the original price at the time you deposited, then your deposit will return to its original value as well. This is why it's referred to as Impermanent. However, just know that these are indeed real losses and should be treated as such.&#x20;

An LP is a deposit into a pair of tokens. One is typically referred to as the risk token and the other as the numeraire. Typically, the stable coin or USD equivalent is the numeraire. For example in a ETH/USDC pair, ETH would be the risk token and USDC is the numeraire.

A concentrated LP changes value different depending on the price. If the price is below the range, then your LP changes in value at the same rate as the risk token. Within the range the LP  changes more slowly than the risk token, and above the LP position no longer changes in value is stays flat. A full-range LP is always within its range so it changes more slowly than the risk token.

For example, if you LP for ETH/USDC  from 2000 USDC to 3000 USDC, then when the price of ETH is below 2000 USDC, the value of your position will fall one dollar for each dollar ETH goes down. When above 3000 USDC, your position will no longer change in value. And between the two there is a smooth transition from one to the other.&#x20;

## Reward

Of course the reason someone would deal with that risk is because the rewards can be high. Especially for well placed positions and even more so when protocols are offering incentives. AMMs typically specify a fee rate or a formula for the fee. Each swap will pay this fee rate on the total size of their swap and this payment is collected as earnings to the liquidity providers. The earnings are split fairly among all positions that are providing liquidity to the range of prices the swap went through. The more liquidity you provide, the more of those fees you get to collect.

This means that as long as you're in range, you'll earn fees. If the price is outside of your LP's range you don't earn anything (unless you're using Ammplify).

## More details

If you'd like to learn more and dive into the technical details, this online book is a great place to start: <https://uniswapv3book.com/>


# Re-LP

"Re-staking" for your AMM LPs.

On Hyperplex you can re-deposit an existing AMM Liquidity Position similar to re-staking ETH on Eigenlayer. Your deposit will still be used to help the base protocol function, but when it's not being productive, we re-direct it to where it can be best utilized to earn extra yield. **Re-LPing** is the process of moving your base liquidity into Hyperplex's bookkeeping.

## Getting Started

For any protocol we support, you can use their UI and deposit as normal and then come to Hyperplex to re-LP, or you can start on Hyperplex and do both at once. At the moment we support only a few AMMs as base protocols, but we'll be expanding quickly. See [Supported Chains & Protocols](/technical-specs/supported-chains-and-protocols) to stay up to date.

## How It Works

When you re-LP, the first thing we do is withdraw your position from the base AMM. Then we split up your LP range into multiple sections to give it [Semi-Fungibility](/technical-specs/semi-fungibility). The range of your liquidity that overlaps with the [LVR Capture](/technical-specs/lvr-capture) tranche is put back into your base AMM, and the rest is directed into your rehypothecation vaults.

### Unconcentrated LPs

For unconcentrated LPs, we aren't able to split up your position and put back only a piece since unconcentrated (V2-style) AMMs only have full-range positions. So for us we actually move your V2 position into a V3-style, concentrated AMM but still provide liquidity to the full-range. This way your risk profile stays the same, and we issue you ERC20 tokens like a regular V2 AMM would, and you can now access all of our features. Plus, typically V3-style AMMs get more order flow. Overall this should be a significant improvement over a regular V2 position.

## Which Features Should I Choose?

We offer a continually expanding list of rehypothecations, reservations, hedges, utilities, and more. You can either be a power user and choose exactly which to use yourself, or you can be a more passive investor and let us optimize and auto-enroll in new perks for you. Either way, we want to reward both types of users.&#x20;

### Power Users (Active Investors)

If you're a power user and choose your own perks, beyond the basic integration fees (which help us monitor risk on the integrated protocols, and pay our engineers to add more integrations) you don't pay any fees like management fees or revenue shares. Many of the free perks like auto-compounding will remain 100% free for you to use. Plus you can sign up to be notified of new perks right when they drop.

### Passive Investors

Passive investing on Hyperplex means signing up for managed perks which will switch you between rehypothecation vaults based on yields and auto-enroll you in higher yielding perks as they are published. In the beginning we'll offer a management service ourselves but overtime we'll decentralize this and allow others to offer their own specialized managements.

When signing up for managed re-LPs, you choose:

1. If you prefer real-yield or incentives (or a mix of both).
2. How aggressive you want to be. Conservative/Moderate/Aggressive.

A conservative real-yield management will minimize smart contract risk, try to get consistently stable yields from well-tested protocols like AAVE, Morpho, and Pendle. An aggressive real-yield management will continually chase after the highest yielding incentives available and auto-enroll into new rehypothecation vaults. Moderate real-yield finds a balance between the two. Incentive managements do the same but look for incentive programs to farm. Real yield management may also chase after some incentives but will quickly sell them into more stable assets.&#x20;

Due to how involved these management strategies can be, we charge a fee for them but only on the yield we earn on top of your base AMM's returns. Our fees will never cut into your original LP position's returns. We are only incentivized to earn more by helping you earn more.&#x20;

Finally, note that we don't actively manage your position range. That is still up to you and you're welcome to use any active managers that integrate with Hyperplex. In the future we'll offer an active price management vault that natively combines price management and perk management.


# Semi-Fungibility

There are lots of optimization protocols for full-range V2 AMM LPs, but very few for concentrated V3 LPs. The reason is because all V2 positions are the same range, so they can issue a fungible ERC20 token for protocols to build around. V3 positions on the other hand can have unique price ranges which is why those AMMs issue non-fungible ERC721 tokens for each position. This makes things like auto-compounders incredibly hard to build because without any special handling, they'd have to compound each NFT position one by one which is incredibly gas intensive.&#x20;

And this is why our Semi-Fungibility is so pivotal. By breaking down concentrated V3 positions into smaller pieces, each individual piece becomes fungible although the overall position remains non-fungible. But these pieces are cleverly shared so pieces from multiple positions can be grouped together for a significant reduction in gas cost. In computer science terms, we reduce the operational overhead from $$O(n)$$ to $$O(log(N))$$.&#x20;

The exact way we do this get's rather complicated. It isn't as simple as just picking a few buckets to split your position into. It follows a tree structure where different levels have overlapping ranges and multiple levels are updated on every action. Overall, we call this structure the Liquidity Tree.

## The Liquidity Tree

The underlying data structure for the liquidity tree is binary-indexed [segment tree](https://en.wikipedia.org/wiki/Segment_tree). We use the liquidity tree to both track our liquidity distribution and the fees accumulated for each range.

The segment tree spans the entire tick range of the AMM. The leaves of the tree cover a single tick and there is one node per tick on the lowest level.  Each level above combines a pair of child nodes into their union'd range. For example nodes on the second level up will cover two ticks, the third will cover four ticks, and so forth. Each node represents a contiguous subrange of the overall price range.

<figure><img src="/files/cZO821VgWbkbhX1S1x75" alt=""><figcaption><p>Example breakdown for the range [1, 8).</p></figcaption></figure>

### Breakdown

When someone deposits a liquidity position into Hyperplex, we split the original range into the minimal set of nodes such that the union of those nodes' ranges will equal the original range. This set can be efficiently computed by walking up from the low end and high end of the desired range.  Once the breakdown is found, all of the deposit's earnings and compounding is calculated on a node basis for each of the nodes in this breakdown.

### Augmentation

The segment tree is further augmented with subtree information which helps us efficiently identify token balances, ambient vault balances, liquidity availability, fee attribution, and more.&#x20;

For example, when we need to distribute fees over the range \[A,B], instead of depositing those fees individually to every tick between A and B, we can simply find the breakdown set for \[A,B] and deposit the fees into those nodes' subtree fee accumulators. Then whenever a node needs to determine their fee accumulation, they walk up the tree through their ancestors and sum the subtree fee accumulators. The depth of the tree is bounded by the logarithm of the total tree range and therefore remains gas efficient.&#x20;

Overall, it is the combination of the segment tree, tree augmentation, efficient breakdown computation, efficient tree walking, and some approximation techniques that enable Hyperplex's advanced accounting capabilities.&#x20;


# LVR Capture

How we tranche liquidity

Our rehypothecation technique has two parts:

1. Keep active liquidity in the AMM where it can collect swap fees
2. Keep inactive liquidity in the rehypothecation vaults.

But predicting which price ticks in the AMM will be active and which won't is rather difficult. If we knew that, we'd be running a liquid fund. Fortunately, when Uniswap V4 comes out with hooks, we can hook into the AMM to do this perfectly but until then we have to instead estimate a range of ticks that will likely be active.&#x20;

This means we can't perfectly capture all the potential rehypothecation yield, but we can get close. This does mean there will be times when unexpected price swings will move the price out of our active ticks and we'll miss out on a few swap fees. It turns out that this is not only okay, it is sometimes even profitable to do. This profit is called LVR capture and is distributed to our depositors.

## Active Range

We specify a range of prices called the Active Range. Any rehypothecated liquidity that falls into this range is put back into the AMM to collect swap fees. This active range is based on the expected price volatility between now and the next time we move the active range. In backtests, this simple strategy captures 99% of swap fees. So for almost all pools this is less than a 1% yield difference, which is easily compensated by rehypothecation yields.&#x20;

This active range setup is similar to an actively managed concentrated LP strategy however because we only allocate the liquidity that you've actually designated for this specific range of prices, your risk is the same as just providing liquidity to your overall position (which is typically wider and less extreme). Therefore this is a way to get the capital efficiency of ultra-narrow concentrated positions with the safety of a wider LP range.

## Loss-Vs-Rebalancing (LVR)

But sometimes not capturing the swap fee is actually profitable. There is a concept in AMM circles called Loss-Vs-Rebalancing which compares how much money you would make by not swapping against a trader, letting the price move without you, and then swapping your own token balances to match the AMM's curve equation balance at the new price. This strategy always outperforms being an AMM LP, but is purely theoretical because it's impossible to achieve in practice without perfect information and instantaneous execution speed. However the concept is valuable and informs us of a different way to make money which is by capturing some LVR profits through intelligently rebalancing the active range.

## Rebalancing

The active range needs to be adjusted frequently to continually contain the ticks that are actively market making. We call this adjustment of the active range a rebalance. Each rebalance will shuffle tokens out of rehypothecation vaults into the newly active ticks and close some liquidity positions to move those tokens back into rehypothecation vaults. &#x20;

We typically rebalance due to two conditions:

1. When enough time has passed and the current price has moved too close to the edge of our active range. This is an LVR-free rebalance.
2. When the price has moved significantly out of our active range. This is an LVR-capturing rebalance.

LVR-free rebalances are simple. We've captured all the swap fees, and just want to shuffle some liquidity around to make sure we continue doing that.&#x20;

### LVR-Capturing Rebalances

LVR-capturing rebalances are more complicated because our re-deposited liquidity positions are now out of range. This means we have to close those positions, open new ones, and swap tokens to to adjust our token balances to fit the AMM curve equation at the new token balance. But notice that this is exactly the definition of LVR. In fact, this swap and re-deposit will leave us with extra value! This extra value is precisely LVR and is distributed back to the liquidity positions that lost out on the swap fees. If this LVR is greater than the swap fees they missed, then this was actually profitable for them!

In our backtests, our LVR captures basically net out against the missed swaps; however for certain pools like pegged assets this can be incredibly profitable. If you LVR-captured according to our strategy during the USDC depeg, you would have made more than three times your annual returns from swap fees alone.

### Risk

Ironically, this type of active range, rebalancing, LVR-capturing set up is safer than a regular LP. In normal operation, there is no difference in principal value between this setup and a regular LP. However, if one of the tokens gets completely rugged and goes to zero, the LVR capturing setup would retain more of the un-rugged token and return much more value back to the unfortunate depositor.

&#x20;


# Core Concepts

Hyperplex re-providing is basically three pieces put together:

* **A Liquidity Disassembler**: We take liquidity and split it into pieces to work with each piece individually. The most important part of this is how we make non-fungible concentrated AMM positions **fungible inside our contract**.
* **A Liquidity Adapte**r: We then take those pieces of AMM and Money Market liquidity and re-assemble them into the right **composition of liquidity** needed to power any given protocol no matter how complex it is.
* **A Liquidity Lending Marketplace**: Finally, we offer liquidity to protocol who need it. They can come to our marketplace and **borrow at a competitive rate**. Since liquidity is borrowed in pieces, your position can be **active in multiple protocols at once**, all being utilized to earn something.

In just three steps, we're able to power new, innovative protocols no matter their design.


# Internal Fungibility

The goal of disassembling.

The main goal of disassembling liquidity is we have to turn Concentrated Liquidity Positions from non-fungible assets into fungible ones. This allows us to interact with the re-deposited liquidity as one large pool instead of a million individual positions.

So counter-intuitively, the first thing to do is turn a re-deposited position into more positions. We withdraw the original LP position, split it into different nodes in [Semi-Fungibility](/technical-specs/semi-fungibility) and redeposit it back as part of those node's LP positions. This turns all the different concentrated positions into similar buckets we can merge together. You can think of it like each individual AMM price tick is its own pool of liquidity, although the reality is far more complicated and gas-efficient.

Now that liquidity is pooled together, we can operate on positions in bulk. This means that whenever someone optimizes any range of liquidity, all other positions in that price range also get optimized. For example, whenever someone opens or closes a position in a given price range, all liquidity in that range is compounded. This is what ultimately allows us to move liquidity into different protocols and lend it around so cost-effectively.


# Liquidity Composition

Putting the pieces together.

Every protocol has different liquidity needs but by composing concentrated AMM and Money Market positions together, we can actually replicate a 2nd-order approximation of whatever liquidity payoff profile they need.

Every protocol has a "payoff profile" which specifies when their users earn and lose money. For payoff profiles based on token prices, just a combination of AMM and money market positions are enough to replicate it. For payoff profiles that depend on time, we use a rate swap protocol (like Pendle) to isolate and remove the time dependency. For other dependencies like competitions and oracles, we tokenize it and give it an artificial price thus reducing us back into the basic setup.

Ultimately, the point is that any payoff profile can be decomposed and rebuilt from a set of basic primitives.


# Borrow/Lending Liq.

At the heart of Hyperplex is a real-time, piecewise borrow/lending market for AMM liquidity that can lend individual ticks or ranges of liquidity.

We effectively have a separate borrow/lending market for every single tick. Unlike regular borrow/lending markets which has no floor APR, our liquidity is deposited into the user's original AMM by default meaning they're guaranteed a yield floor.

When a protocol borrows liquidity (on behalf of their user), they are required to

1. Pay any fees your deposit would have earned had it stayed in the original AMM. This way users don’t lose any fee earnings (which is guaranteed by a collateral deposit).
2. Return the liquidity according to the original AMM’s curve equation. Again, borrowing **cannot** negatively impact the LP position.
3. The borrower must pay a funding rate based on demand just like a regular money market. So if there are a ton of borrows at a given tick, they would have to pay an incredibly high funding rate. As a result, lenders earn strictly more than their original deposit would on its own.


# Convexity

Why someone would borrow liquidity.

When someone borrows AMM liquidity, they're not just borrowing the tokens but the Impermanent Loss exposure as well.&#x20;

When someone liquidity provides to an AMM, they are selling their token upside potential for yield. Due to the curve equation, if the token moons, the LPer captures fewer profits. If the token dumps, the LPer captures all the losses, but during that time they'll also earn yield. The hope is that the yield outweighs the missed profits. Those missed profits are what people call Impermanent Loss or IL.&#x20;

When someone borrows AMM liquidity the first thing they do is convert it into one of the two tokens in the token pair. Whichever token they convert the liquidity's assets into, the position is now back to getting all the upside exposure and downside exposure of the token. They're basically betting that those missed profits are actually greater than the yield an LP would earn. They're willing to pay the AMM the borrowed liquidity's missed swap yield plus a utilization based fee in return for capturing those missed profits for themselves. The best part of this type of position is that the borrower doesn't experience any downside from the token price dropping. If the token price goes down remember that the original LP position was willing to take on that risk anyways. So the borrower simply returns the token for no loss (besides any fees paid) if the price drops.&#x20;

If this type of "borrowed" LP position sounds a lot like an option, that's because it is! They both operate off of the same financial principal of convexity which is used everyday throughout the global financial system. Without it, insurance, home loans,  car loans, corporate bonds, and more would not exist.

If that was confusing, here's a step-by-step slideshow explaining convexity with an example.

{% embed url="<https://docs.google.com/presentation/d/1eYOideuMan9vIcc2-3y-DZ95Uv2V47rlo74VayGZxEw/edit?usp=sharing>" %}


# Liquidity Multiplexing

The secret to farming multiple yields at once.

Finally, this is where our name comes from. **Multiplexing** is a term in computer hardware design where multiple streams of information funnel into a single stream. That is what Hyperplex does with yields. There are tons of defi opportunities but they appear at different times, use different types of liquidity, and earn different amounts. We direct all those different streams into one funnel so our users can earn more with one simple deposit.

That funnel is the Liquidity Borrow/Lending market. Every protocol can be thought of as a trading strategy. They provide an asset for their users by charging a price and most of those fees goes to their liquidity providers who are essentially financing that trade. Through lending, Hyperplex users can finance any of these trades in a simple way that still stays within the AMM risk model.

Mediation contracts or the protocols themselves borrow the pieces of liquidity and employ them in their trades to create what their users want. At any moment, your liquidity is most likely spread among multitude of these liquidity borrowers earning from multiple income streams.

<figure><img src="/files/bzXsbKVlbkDRKgCiIFI6" alt=""><figcaption><p>A simplified mental model of how Hyperplex works.</p></figcaption></figure>


# Liquidity Perks

You can stack multiple perks on your re-provided liquidity position. Each layer offers its own unique risk/reward so it's important to choose a specific combination that's most suitable for your needs.&#x20;

Currently we only offer re-staking for Concentrated AMM LPs and we offer only a handful of layers but that'll grow quickly in the future. For now, let's explore the three types of layers: [JIT Yields](/technical-specs/liquidity-perks/jit-yields), [Utilities](/technical-specs/liquidity-perks/utilities), and [Strategy Yields](/technical-specs/liquidity-perks/strategy-yields)

## List of Layers

1. JIT Yields
   1. Floating Lend - The central lending utility. Borrowers pay more than the base yield to borrow.
   2. Itos Lend (Coming soon) - The Perp Options protocol Itos borrows by paying the base yield and incentives.
   3. Wumbo Lend (Coming soon) - [wumbo.fun](https://wumbo.fun) borrows to support their 1-minute expiries.&#x20;
2. Utilities
   1. Auto-Compounding - Zero-Fee automatic compounding for Concentrated AMM Liquidity.
   2. IL Hedged (Coming soon) - Cap your Impermanent Loss.
   3. Floor Value (Coming soon) - Secure a floor value to your liquidity position.
3. Strategy Yields
   1. Ambient AAVE - Deposit inactive liquidity into AAVE to earn lending yield.
   2. Ambient Notional & Delta Prime (Coming soon) - More lending market depositing.
   3. GMX Basis Farming (Coming soon) - Farm high funding rates on GMX.

With many more to come.


# JIT Yields

These yields are earned from protocols **actively borrowing** liquidity (see [Liquidity Lending](/technical-specs/liquidity-lending#multiplexing)). JIT Yields are the type of yield most similar to what liquidity providers usually farm and stacking multiple JIT Yields is an easy way to farm multiple protocols.

Currently, there are two types of JIT Yield layers:

* **Floating Lend:** This is the standard liquidity lend. Just like a borrow/lending market on tokens, this lets protocols borrow liquidity at a rate based on demand. But unlike regular borrow/lending markets, borrows for liquidity also need to pay the earnings rate of the base protocol they're borrowing from.&#x20;
* **Reward Lend:** This is a floating lend but instead of paying the standard fee rate, the protocol pays its own rate, usually a combination of real yield and an incentive yield.

Regardless of the type of lend,  when liquidity is borrowed and returned, it is returned according to any curve equations in the base protocol. This makes JIT Yields generally extremely safe.&#x20;

At this moment, **we only allow users to opt into 1 Reward Lend** at a time. This is due to gas constraints and as gas continues to cheapen we can allow more combinations.

### Format

All JIT Yield Layers show four important stats:

* **Lend Yield**: The yield it provides **when active**. A real yield and an incentive yield.
* **Utilization**: How often it is active.
* **Reserve Yield:** The yield always given to positions that opt-in because these layers might have restrictions.
* **Capacity:** How much can be deposited into this layer.&#x20;

Note that because the borrow isn't happening all the time, the total yield is the **lend yield times utilization plus the reserve yield.**

#### Lend Yield

When a protocol borrows your liquidity away from say Uniswap, they have to pay Uniswap would have paid your liquidity plus an extra fee. We call this the base yield and the premium. The main lending layer, **floating lend** charges one consistent rate for everyone.

However some protocols might offer token incentives instead of premium, or instead of the base yield and premium, or even instead of a portion of the base yield. If the incentives are high enough, this might be worth opting into. When making that decision, it is good to look at the **utilization**.&#x20;

#### Utilization

The utilization is how often the protocol for this layer has borrowed liquidity in your range. A high utilization means you'll be borrowed often which means you won't farm other protocols and the base protocol as much. This might be great if the incentive is high, but if you want to diversify your rewards, it is good to use lower utilizations.

You can find your base protocol's utilization rate in the pool details for comparison. As a rule of them, your position is most predictable if your total utilization (including your base utilization) doesn't sum to more than 100%.

**Reserve Yield**

Some protocols offer passive yield to depositors regardless if they actively borrow your liquidity or not. This might be so you'll opt into them even though their lend yield is low or their utilization is somewhat high or they're **mutually exclusive** with other layers.

**Mutually exclusive** means you won't be able to opt into certain other layers if you choose this one. Protocols opt into this when they want to guarantee a certain amount of liquidity is always available for them to borrow. Protocols might have one high-paying exclusive layer and one regular non-exclusive layer. The exclusive layer is often limited by **capacity**.

#### Capacity

This is how much liquidity is allowed to opt into the layer. High-paying layers or layers with reserve yields only want to reserve a limited amount of liquidity. **Capacity** indicates how much space there is still available to positions in this layer.


# Options?!?!

The biggest use case for Floating Lends is for creating things like on-chain synthetic options and structured products. In fact the combination of borrowed AMM liquidity, regular AMM liquidity, and token borrow and lends can create any token payout.

We strongly believe that long-term this will find PMF once regulations loosen. Even in the near term there seems to be lots of synthetic option protocols coming to market and they can easily integrate with Hyperplex for liquidity sourcing!

For now, [Itos](https://docs.itos.fi) will be our first borrowing integration. See more details there!


# Utilities

Utilities modify your liquidity position in different ways with a clear technical specification. They don't always provide higher yields and may even decrease them but can offer different benefits instead.

Examples include Auto-Compounding, Hedging, Delta Adjustment, Leverage, Cross-Margin, and more.


# Auto-Compounding

This is true zero-fee auto-compounding for Concentrated AMM liquidity!&#x20;

This can make an enormous difference, especially at higher yields which concentrated positions are known for.&#x20;

<figure><img src="/files/MOGIL4KioPuO4dszYbZq" alt=""><figcaption><p>Comparison of Compounding vs. Not</p></figcaption></figure>

### Old V3 Auto-Compounders

Existing auto-compounders don't compound for everyone. They allow other users to compound a single LP position by withdrawing and re-depositing in return for collecting a fee. This has multiple effects:

1. It does compound the position and the yield for that position is increased.
2. The fee is often significant and degrades the performance of the position.&#x20;
3. Small positions don't earn enough fees to justify the compounding fee. Therefore they're either not compounded or their performance is severely harmed.

### How it works

So how are we able to make do it without charging any fees? Well the trick lies in our [Semi-Fungibility](/technical-specs/semi-fungibility). All re-staked LP positions are actually broken apart and merged into the pooled position within each node. That means no matter the number of re-staked positions there are, the number of positions we have to compound never grows.

Second, every time a user re-stakes or un-stakes, we have to close and reopen the tree's nodes in their range. When that happens we take the opportunity to compound those nodes. Thus any action taken on our platform helps compound the positions of everyone in that same  pool!

### Who can opt in?

Any concentrated AMM position re-staked on Hyperplex can use this as a utility at no cost! No other layers are needed.&#x20;


# Page


# Strategy Yields

Strategy Yields are layers that don't have strong yield guarantees like [JIT Yields](/technical-specs/liquidity-perks/jit-yields), but often give higher returns or add additional yield in different ways. They are still based on borrowing liquidity and will also return the liquidity according to any curve equations like JIT Yields.

These yields are similar to what you would find from yield aggregators or vaults.  They are typically statistical arbitrages such as rate swaps or perp funding and can get pretty advanced so users are advised to do their own research before opting in.

The most important category of Strategy Yields are **passive strategies**. They deposit inactive AMM liquidity into other protocols like borrow/lending pools to layer lending yields on top of the AMM swap yield. One such strategy is [Ambient AAVE](/technical-specs/liquidity-perks/strategy-yields/ambient-aave).

### Format

* **Reward**: The yield it provides to utilized liquidity.
* **Utilization**: The percent of re-staked liquidity it utilizes on average.&#x20;

Unlike JIT Yields, passive strategies are always active but don't use the entire pool's liquidity. This is because it has to leave some behind in the base protocol to earn the base yield.


# Ambient AAVE

This is a Strategy Layer that uses **Tranche Borrowing** ([/pages/927xaNZXvR5qNAkd7idp#range-vs.-tranche](https://docs.ammplify.xyz/technical-specs/liquidity-perks/strategy-yields/pages/927xaNZXvR5qNAkd7idp#range-vs.-tranche "mention")) to take the inactive ticks deposited for an AMM and move them into AAVE to earn the lending premium.

### Reward

The reward is a straight forward yield: \~30-40% of each token's lending APR.

E.g. An ETH/USDC pool where the ETH lending APR is 3% and USDC APR is 10% gets an average boost of +4.55%.

### Risk

There are two risks:

* [The Tranche Rebalancing Premium](/technical-specs/liquidity-lending/the-tranche-rebalancing-premium) since it is a tranche borrowing strategy.
* **Illiquidity**: It's possible the entire AAVE pool for either of the two tokens is totally borrowed out and because of that we can no longer swap. This is okay and perhaps even profitable for a few reasons:
  * The downside is we would no longer earn any swap fees.
  * The upside is the lending APR increases dramatically if the entire pool is borrowed. For b-tier tokens where this has a non-trivial probability of happening, that APR is roughly 300%. (We'd like this number to be higher and are exploring other lending pools.)
  * The *most important* reason though, is if the entire pool is borrowed out then the token is must be experiencing incredibly high volatility. That is NOT the time you want to be LPing. The impermanent loss will be much higher than any swap fees so in that case it's better to just sit tight.

### How it works

For a given pair, say ETH/USDC, a given liquidity tick is entirely in USDC if the current price is above it and entirely in ETH if below. So for inactive tick tranches above the current price, we move their assets (which is ETH) into AAVE and move it back when the tranche is close to being active. And for tranches below, we move their USDC into AAVE in the same way.&#x20;

So while the average is \~30-40% in each token, just know that if your range is mostly below the current price you'll be collecting more USDC yield and if your range is above you'll collect more ETH yield.


# Page 1


# Liquidity Lending

How the re-routing magic happens.

Lending liquidity is how we redirect liquidity from one protocol to another. There are two ways this can be triggered, **Active Multiplexing and Passive Multiplexing borrows,** two types of borrows that can be initiated, **Secure and Insecure Borrowing,** and two types of borrow sizing, **by Tranche and by Range.**

**Remember that any user can opt out of allowing Range borrows, Tranche borrows, or both. If you just want a few utilities on top of your basic LP and no fancy yield stacking, more power to you!**

## Range vs. Tranche

* A **ranged borrow** borrows liquidity from a given price range. To satisfy this the liquidity tree finds the proper breakdown for that range and inserts negative balances into its bookkeeping. Then Hyperplex actually sources the liquidity from those nodes which means either removing it from the base protocol or from a tranche borrow. When sourcing, if the exact nodes for the desired breakdown has insufficient liquidity, then it borrows from parent nodes. If parent nodes are insufficient, the borrowing protocol should split the range into distinct calls to utilize child nodes.
* A **Tranche borrow** is specific to AMM liquidity. The AMM's ticks are split into tranches according to their distance from the current token price as indicated by a Chainlink oracle. Only the tranche containing the active tick is deployed to the AMM to collect fees. The other tranches are deployed to passive sources of income such as money markets. When the oracle changes, a call is made by our off-chain infrastructure to rebalance if necessary.&#x20;
  * There is hysteresis in the rebalancing requirements to minimize rebalances.
  * This rebalancing is not like AMM liquidity rebalancing. Your out of range liquidity remains out of range and your IL risk is not increased. This rebalancing does not pose a risk to users, it only affects capital efficiency.
  * Tranche sizing is based on the token pair's volatility.
  * There is the rare possibility that a large swap moves the price directly into another tranche, therefore we'll miss a portion of the swap fees for that specific move. While that may be true, this is actually profitable for tranche borrowed liquidity. See [The Tranche Rebalancing Premium](/technical-specs/liquidity-lending/the-tranche-rebalancing-premium) for details.

## Secure vs. Insecure Borrowing

* **Secure borrows** interact with Hyperplex, can manipulate the liquidity on Hyperplex, but never actually removes assets off of Hyperplex's smart contract. Additionally, they have to collateral for these borrows. The collateral to ensures they can pay fees and return the assets to their original constraints. These borrows are extremely safe.
* **Insecure borrows** actually move assets off the Hyperplex smart contract and promise to return it at a later time. For these the team and the borrower's auditors  throughly inspect any potential sources of risk. The fees charged to these protocol are higher and extra security guarantees like circuit breakers are implemented. These are riskier, but often result in higher returns.

## Multiplexing

An **active multiplexing** borrow is initiated by a protocol who needs to immediately reroute to satisfy a user's demand. For example, if someone opens a perpetual option the liquidity is rerouted in the same transaction as that open and is return in the closing transaction.&#x20;

A **passive multiplex** is a borrow that is less time sensitive and is often initiated by us. The requirements are validated on chain so in theory anyone can initiate a rebalance of a passive multiplex. These are not tied to any users but are managed by a strategy manager who might be a smart contract automating some requirements or an actual team of people. An example is the [Ambient AAVE](/technical-specs/liquidity-perks/strategy-yields/ambient-aave) layer, where we deposit inactive ticks into AAVE to collect a money market yield.&#x20;


# The Tranche Rebalancing Premium

Because of Tranche-ing, when a large swap causes an AMM's active tick to rapidly change, the price might move into a new tranche whose liquidity is not yet deployed. This means that tranche's liquidity will miss out on that swap's fees. That sounds bad at first, but there's actually upsides as well. Let's take a look.

### Position Balances

Let's examine the example of a sudden price move up, and a single unit of liquidity. We'll pretend the liquidity is deposited in an infinitesimally small range since that can generalize to any tick width by simply adding them together. Let's say that range is right around the price 3000.

For any liquidity position, it always holds the less valuable token on either side of its price range. So for ETH/USDC, if the price goes above the range it'll swap to all USDC and if the price goes below the range the position is swapped to entirely ETH. This is where IL comes from, you miss out on the gains of ETH, but still capture its downsides.&#x20;

So for our position, above 3000 we'll have all USDC below 3000 we'll have all ETH. Now in our scenario, this unit of liquidity is "tranched", so it isn't deployed to the AMM and doesn't get swapped into USDC. This means as the price shoots up, it actually gains in value and profits from the move.

And that profit as a percent is exactly the percentage increase of the resulting ETH price over the liquidity's price of 3000.&#x20;

<figure><img src="/files/C9ZcaDgeIA8T2VX6q35P" alt="" width="375"><figcaption><p>A unit of liquidity that doesn't swap during a price move.</p></figcaption></figure>

### Positional Profit vs. Swap Fees.

Therefore, we really just need to compare if this profit is larger than the swap fee. Given that most swap fees are as small as 0.05% and 0.3%, it is extremely likely the price will go more than 0.05% or 0.3% past the liquidity's range. This is basically the heart of the Loss vs. Rebalancing argument you might have seen on crypto Twitter.

Our tranche sizes are typically set to a band width of the 1-day price volatility around the current price and rebalanced when the price moves halfway to either end. So a swap would have to jump half of 1-day's price volatility to go out of tranche. Therefore if the price is jumping 5-10% to go out of tranche, what is the probability that it only goes less than 0.3% past the liquidity tick's price.

"There are decades where nothing happens and weeks where decades happen" is an apt quote for crypto. We'll present data later on as this strategy plays out, but given the volatility of crypto we believe suddens moves are **sudden**, and the probability that your tick is within the very last 0.05% or 0.3% of the price move is very low. In fact if the price moves just a bit more than 0.06% past the tranche range a random un-swapped tranched tick is more like to be profitable than not.

### Caveats

But you might say "what if you miss multiple swaps?". And that's a good point, because the position's profit is a one time thing, but there can be multiple swaps back and forth before a tranche rebalance happens. We've partnered with great data providers and RPCs to minimize that delay but I can't promise there won't be any, so it is possible. On the other hand though, avoiding all passive strategy yields is a much bigger opportunity cost than these marginal swap fees.


# Supported Chains & Protocols

Ammplify makes the most sense when deployed on multiple chains because our value-add is chain-agnostic. And long-term we're working on allowing for cross-chain liquidity multiplexing. However in the short-term, we'll be doing our initial launch on Berachain and Monad before including Arbitrum and Base.

**Berachain's** innovative Proof-of-Liquidity works fantastically with our re-depositing mechanism, effectively allowing users to double-dip and maximize their BGT farming while powering a thriving DeFi ecosystem.

A **Monad** deployment will follow shortly. Given the founding team's background in traditional finance and their high transaction throughput, Monad is well suited for derivative protocols which is where Hyperplex really shines.

At launch we'll support Uniswap V3 and Uniswap V3 forks before moving to other concentrated liquidity pools like Ambient Finance and Algebra.


# Smart Contract Details

An in-depth description of the Ammplify smart contract.

## High-Level Description

Ammplify is a protocol that wraps UniswapV3, manages deposits by breaking them into smaller pieces.

This means when a users deposits a typical UniV3 range, we split it into smaller pieces and re-deposits them back into UniV3. The reason to do this is because each piece falls into a bucket and all liquidity within each bucket is fungible. This allows us to apply two optimizations on each bucket: auto-compounding and borrowing.&#x20;

In contract, the buckets are nodes in our segment tree and borrowed liquidity is called Taker liquidity. Regular liquidity is called Maker liquidity and Maker liquidity is split into a compounding version and a non-compounding version.

## High-level Architecture

Ammplify is built according to the Diamond standard (EIP 2535) and it installs these facets:

* Maker Facet (For opening and closing liquidity positions)
* Taker Facet (A privileged facet for borrowing liquidity)
* View Facet (For examining contract storage)
* Admin Facet (For managing Taker rights and time-gating and protocol changes)
* Pool Facet (For interacting with the underlying pool)

The meat of the complexity is in the Walker library called by the Maker and Taker facets to deposit/borrow liquidity to/from the nodes in the segment tree stored in the tree folder. The majority of the tree logic is in Route.sol.


# Walker Lib

The Walker lib uses a segment tree to manage fees and liquidity over each node.

Each node's key tells us the liquidity range a given node owns. The keys range is scaled up by the tick spacing and then offset so the center of the tree range matches with tick zero in the pool.

## Modify

When modifying liquidity, we walk down first to distribute unpaid and unclaimed fees, and then we walk up to create new unclaim/unpaids, charge accurate fee rates, and update liquidity.

### Fee Down

When modifying fees down, we are only concerned about the unclaimed and unpaid fees. These are fees that can be claimed by maker liquidity and paid by taker liquidiy respectively.&#x20;

On the way down we track all the liquidity values in parent nodes so that at any moment during our walk down, we can say exactly how much liquidity is in the current node's range. We call this column liquidity. If you imagine each level of the tree spanning the entire tick space, and each node in a level spanning an equal portion of that tick space, which each level below spanning the space using twice as many ranges each half as wide then the "column" of a node is all ranges above and below it covering the same range. In other words it's simply the amount of liquidity in a given range as contributed be all nodes in total. We will use this prefix on the way up.

On the way down however, we are just concerned about the subtree liquidity among a node's two children. This tells us how to split the unclaimed/unpaid fees between them. The node itself takes a pro-rata split of the unclaimed/unpaid according to this entire subtree's maker/taker liqs. Then it calculates weights for each children based on their subtree maker/taker liqs. The split rate is used to calculate how the unclaim/unpaid are split into each node and then we recurse.

This is called "distributing unclaimed fees" and this only happens when a node is walked over. So a node can be accumulating a large amount of unclaimed fees over a long period of time, which is only settled once it is actually walked over. Fortunately to modifying liquidity or claim fees from nodes below it, that node must first be walked over.

<details>

<summary>Toy Distribution Example</summary>

Here's a toy example with 3 nodes covering 2 ticks.

\[0,2] has 100 liq (per tick).\
\[0, 1] has 100 liq, and borrows 100 with taker liq. \
\[1, 2] has no liq and no borrows.&#x20;

From subtree values, the root node sees 300 total liq, and 100 borrows, so it charges say 15% for 33% utilization. It says anyone in this subtree borrowing must pay 15%. It sees it has no borrows, so it doesn't charge anything to its borrowers. It sees it has maker liq, so it says 15% of the 100 borrow (15) gets paid pro-rata to my makers, so it gets 10 fees (200 / 300 \* 15). Then it splits the rest (5) to its children, which it sees has no borrows on the right, so it gives it all as unclaimed to the left, and all of the 15 charged is given as unpaid to the left and 5 is given as unclaimed to the left.

This distribution might seem unfair here, but in practice the borrow distributions between adjacent nodes will be relatively even since otherwise there is an arbitrage.

</details>

### Fee Up

When we walk up, the first thing we do is calculate fees since we want to do that before modifying liquidity values. Here we use the prefix and unwind the prefix as we walk up.

Using the prefix and the subtree values stored in the node, we can calculate the column's maker and taker liquidity values and thus its taker utilization. This allows us to calculate the fee rate to charge all takers in this column. We do this calculation at the deepest node we'll visit in a subtree during our walk, and this happens when a node is marked "visit" by RouteLib. This calculation gives us the "fair" rate of borrowing and we charge those fees to the current node. Since this fee rate applies to all liq in its column, we charge it to our subtree and distribute it as unclaim/unpaid fees to our children, and then as we walk up we propogate up that fee rate, joining it with our sibling node's fee rate to get our parent node's fair fee rate, ultimately reaching the root node.

Besides the taker's fee rate calculation, we also need to charge takers the underlying swap fees of the maker to guarantee all maker liquidity earns the same amount as they would in the base AMM, borrowed or not. We simply track inside fee rates (see Uniswap documentation) to calculate this.

### Liquidity Up

As we walk up, we also modify the liquidity (maker/taker) at each node. By doing this just as the visit nodes, we'll give users a liquidity range that is equal to their desired overall liquidity range.&#x20;

Before modifying liquidity however, we must first compound if necessary. The amount of fees available to compound Maker liq is calculated and the node grows its maker liq balance accordingly.

After modifying liquidity, it's possible that a node's liquidity is insufficient for the taker borrows, but it's possible an ancestor node has sufficient liquidity. So the solving step will borrow liquidity from a parent node, split it into our own node's liquidity and our sibling's liquidity, and satisfy the taker borrow. So the node's overall net liquidity is always greater than or equal to zero.

## View Walker

The view walker is used to calculate how much a position is worth. It basically does all the fee calculation steps without any state modification and skips the liquidity modification step.

## Pool Walker

The pool walker is what finalizes any liquidity changes made by the Modify walk. It looks at which nodes are marked dirty, and updates liquidity values in the actual pool accordingly.

## Potential Confusion

The word borrow is unfortunately heavily overloaded in our codebase. It may refer to:

* Taker liquidity, since that borrows liquidity from makers, but we avoid using it as such in code. However in comments we may talk about how it borrows liquidity.
* Token borrows. node.liq.subtreeBorrowX for example refers to the amount of token X that is borrowed by Taker liquidity from the subtree.
* Maker liquidity borrowed from an ancestor. When solving a node's liquidity, liquidity lent by the parent is stored as a borrow in the child node.

Token0 and token1 are interchangeably used as tokenX and tokenY. 0,1 is uniswaps convention, but our notes use X,Y. We use both in our codebase, using 0,1 more when we interact with Uniswap and X,Y in our own accounting.


# src/tree/

This is basically our implementation of a segment tree in Solidity <https://en.wikipedia.org/wiki/Segment_tree>

Nodes are identified by Keys, and their walking procedure is handled by Routes.

We walk down starting from the root to the leftmost node of your range and then we walk to the right most root of your range. Along the way we will visit the nodes that constitute the required intervals such that the union of them all is your total range. We mark those nodes as "visit" nodes.&#x20;

The exact walk procedure goes from the root to the lowest common ancestor (LCA) of your leftmost and rightmost visit node. Then we proceed from the LCA to the left node and then from the LCA to the right node before walking back up from the left node to the LCA, the right node to the LCA, and then the LCA to the root node.

Between each of those steps, a phase function is called to indicate the end of the previous phase so users can do any bookkeeping changes as necessary.&#x20;


# Assets

We store user positions as Assets which store their original liquidity balance, the liquidity type, and node information for each node they use in AssetNode. We essentially keep track of an Assets fees and liquidity balance by tracking them separately for each node they use in the tree.

These AssetNodes are updated during WalkerLib.modify.


# Whitepaper

Borrow/Lending Liquidity: Coming soon


# Videos

Our Monad Madness pitch (where we won the community prize!):<https://youtu.be/39xuOQnIqYQ?t=5661>

Our Eth Taipei talk on underwriting derivatives with AMM liquidity: <https://www.youtube.com/watch?v=jdKPS-XoUUQ&t=23527s>


