# Litepaper

Version 1.0 (12.23.2021)

## Introduction

### What is HedgeCat Protocol

HedgeCat Protocol is a decentralized margin trading protocol built on concentrated liquidity from popular AMM-based decentralized exchanges. For those unfamiliar with margin trading, trading on margin means borrowing money from a provider to carry out the trades. When trading on margin, traders first deposit cash that serves as collateral for the loan and then pay ongoing interest payments on the money they borrow. This loan increases traders’ buying power, allowing them to buy a larger quantity of securities. The securities purchased automatically serve as collateral for the margin loan. Significant features of the HedgeCat Protocol:

Hedging/Profit tool for liquidity providers

Existing liquidity from AMM-based DEXs like Uniswap, Sushi-swap, etc., can be introduced directly into HedgeCat Protocol. It helps liquidity providers to earn profits rather than the existing DEX transactions fee. Furthermore, it provides an efficient hedging possibility for liquidity providers. The impermanent loss of AMM-based DEX is a high risk for liquidity providers. HedgeCat can effectively protect their wealth, particularly when the market fluctuates massively.

Non-liquidation

The margin for concentrated liquidity is a fixed value at any time. The HedgeCat algorithm ensures the margin is always safe for the loan. As a result, no liquidation process is required throughout the system.

Support all trading pairs

HedgeCat Protocol takes external liquidity as counterparties. Therefore, any trading pairs supported by DEXs can be supported by HedgeCat Protocol directly. The first version of the HedgeCat protocol focuses on Uniswap V3, using the concentrated liquidity mechanism. The next version will expand to all the AMM-based DEX, which provides liquidity providers with a way to wrap their LP token with the concentrated property. The next part will show the principles and examples to illustrate how HedgeCat Protocol makes the above features possible. Before reading the following sections, it is recommended to understand the concept of concentrated liquidity first. You can learn more about concentrated liquidity by reading this piece.

### Project Vision

HedgeCat Protocol aims to change the structure of decentralized derivatives trading mode.

We will take advantages of decentralized exchanges and introduce the margin trading on concentrated liquidity to provide a a more secure, robust, and easier-to-use derivatives trading platform.

## Margin trading on concentrated liquidity

Before other topics, the most important thing to understand is how to make a margin trade on concentrated liquidity. Different from traditional margin trades, in HedgeCat Protocol, the trader borrows concentrated liquidity from the Provided Liquidity by depositing full collateral and paying funding payments in advance for a selected period of time. After that, the trader will change the composition of concentrated liquidity depending on his anticipation. When the price changes in the trader’s anticipation or the margin trade comes to a deadline, the trader will change the composition of concentrated liquidity according to the current price and make a profit through spreads. Here is an example showing how the margin trade happens on concentrated liquidity

Liquidity provider Bob stakes his assets pair (4000 UDSC, 1 ETH) into the Uniswap V3 swap pool as liquidity (Assume the current ETH price is 4000$), and receives an NFT for proof of concentrated liquidity with setting an upper bound of 5000 USDC / ETH and a lower bound of 3000 USDC / ETH.

By comparing the transaction fee received from Uniswap V3 and the possibility of profit in HedgeCat, Liquidity provider, Bob stakes his liquidity tokenized NFT into HedgeCat Protocol with a fixed duration and sets a funding rate he wants to earn. Notice that before some traders borrowed this liquidity token, Bob could still get all the transaction fees from this concentrated liquidity.

Trader Alice decides to borrow Bob's liquidity as margin and open a position. She pays the Margin (412 USDC) and funding payments (suppose Bob set the funding fee as 200 USDC for one week) to borrow the liquidity tokenized NFT( the calculation of margin will be given in the next section).

Trader Alice would like to short ETH in the HedgeCat protocol. In the first step, HedgeCat Protocol will help Alice change this NFT composition from the original position (4000 UDSC, 1 ETH) to only composed of USDC (8000 USDC, 0 ETH) at the ETH price 4000 USDC / ETH by using the Uniswap V3.

Imagine the price of ETH drops to 3500 USDC per ETH. At that moment, Bob’s original value of that liquidity token was worth 7500 USDC ( the current position of the initial liquidity is 2600usdc and 1.4eth calculated according to the current Uniswap ETH/USDC pair). So now Alice gets profit, and she can close the short position. Alice will ask Hedge protocol to take 7500 USDC to repurchase the NFT (concentrated liquidity) with the same position of the original liquidity of Bob at the current price and close the short position. Now Alice can obtain her profit (8000 USDC - 7500 USDC = 500 USDC).

On the other hand, if the ETH price increases to 5000 USDC / ETH, the original value of that liquidity token provided by Bob is worth 8412 USDC (composed of 8412 USDC only, 0 ETH). Now, if Alice closes this position, the HedgeCat protocol will take the 412 USDC margin from Alice and 8000 USDC from original liquidity and then reimburse the liquidity NFT to its target value. This close action means Alice loses her whole margin, 412 USDC. However, if Alice would not like to close the position at that price now, and the position was not overdue (1 week period in this scenario), then Alice can keep that position, and no one else can liquidate it till the deadline.

Finally, after a fixed duration or no trader has used this liquidity as a position, Liquidity provider Bob can claim NFT(concentrated liquidity) and claim the funding payments from Trader Alice.

## Margin Calculation principal

From the above user case, we now know how HedgeCat Protocol works. There will be formulas and functions in the following sections that explain the margin calculation and the value of tokenized liquidity.

### The upper tick and lower tick for concentrated liquidity

Figure 2.1 displays when the curve $x \times y=k$ shift left down, will have two intersections: upper tick and lower tick. If the price is out of this range, the liquidity will no longer participate in the transaction. This means the compositions of concentrated liquidity will not change out of the price range (we mark the price at the upper tick as $P_b$, the price at the lower tick as$P_a$, the amount of liquidity provided can be measured by the value$L$, which equals to$\sqrt{k}$).

### The quantity relationship of token0 and token1 in liquidity

From figure2.1, we find that the quantity of token0/token1 will not change out of the price range. And in the range, quantity satisfied the formula:

$(x + \frac{L}{\sqrt{P_b}}) \times (y + L\sqrt{P_a}) = L^2$

We can simplify that formula to：

$\Delta y = \Delta \sqrt{p} \times L$ , $y \in [0, L\sqrt{P_b} - L\sqrt{P_a}]$

$\Delta x = \frac{1}{\Delta \sqrt{p}} \times L, x \in [0, \frac{L}{\sqrt{P_a}} - \frac{L}{\sqrt{P_b}}]$

And shown in the graph can be:

### The value of concentrated liquidity calculation

Suppose token0 is USDC and equals 1 dollar. Then, we can get the concentrated liquidity value expression: ($P_c$ is current price for token1)

$v = (x + \Delta x)\times P_c + (y + \Delta y)$

Combine the result from 2:

$\Delta y = \Delta \sqrt{p} \times L$, $y \in [0, L\sqrt{P_b} - L\sqrt{P_a}]$

$\Delta x = \frac{1}{\Delta \sqrt{p}} \times L, x \in [0, \frac{L}{\sqrt{P_a}} - \frac{L}{\sqrt{P_b}}]$

We can get the result:

$P_c \leq P_a : v= L(\frac{1}{\sqrt{P_a}} - \frac{1}{\sqrt{P_b}})\times P_c$

$P_a < P_c < P_b: v = L(\frac{2\sqrt{P_c \times P_b} - \sqrt{P_a \times P_b} - P_c}{\sqrt{P_b}})$

$P_b \leq P_c: v = L(\sqrt{P_b} - \sqrt{P_a})$

In the coordinate system, it looks like:

### Margin calculation

From figure 2.3, we can find that the value of concentrated liquidity will not increase after exceeding the upper tick price. If we take the difference between the MAX value and current value as margin, it can always cover the loss of concentrated liquidity. And the margin formula can be concluded as:

$M_1 = L(\sqrt{P_b} - \sqrt{P_a}) - L(\frac{2\sqrt{P_c \times P_b} - \sqrt{P_a \times P_b} - P_c}{\sqrt{P_b}})$

We can also get the margin ratio formula by the margin divided value of concentrated liquidity：

$R_1 = L(\frac{2\sqrt{P_c \times P_b} - \sqrt{P_a \times P_b} - P_c}{M_1\sqrt{P_b}})$

## System Design

Liquidity providers stake their LP(NFT) to HedgeCat Protocol.

The trader chooses the specific pool to open a position, by depositing the margin and the funding payment.

HedgeCat protocol decreases liquidity amount of staked LP(NFT), acquires token and records the value.

The user closes the position and redeems the margin and profit.

When liquidity providers unstake liquidity, they can claim the funding payment from users.

Liquidity providers get governance incentives, and traders get trading incentives.

### Funding Payment and Withdraw penalty

#### Funding Payment

Unlike Dydx or Perpetual protocol, whose funding payments depend on the current market price and future price, the funding fee in HedgeCat protocol entirely depends on the liquidity provider’s preference. Therefore, it finally keeps the funding fee as a market behavior to get the high profit and attract more traders to open positions and use it.

One example to illustrate:

Liquidity provider Bob has an NFT for proof of concentrated liquidity, and Bob estimates the NFT APY in the transaction pool is 30%. When Bob stakes his NFT in HedgeCat protocol, he set a factor based on 30% ( 30%$\times$1.5 = 45%), which is 45% as his NFT position funding payment factor.

When Trader Alice would like to open a position with 20% of Bob's NFT(value is $v$) for one week, the funding payment of this transaction should be

#### Withdrawal Penalty

The liquidity providers in the HedgeCat protocol are the key players of our product. They provide the liquidity which traders can borrow to open the position. In terms of each liquidity token, the provider will determine a duration that this liquidity can be used, e.g one day or one week. However, when the liquidity provider needs to claim it back in some cases, it is accepted by HedgeCat in principle with some penalties applied. The penalty will be a ratio multiples the collateral that traders paid in the beginning of the trading. The initial value of ratio is `2.0`

which can be modified by governance proposal later.

### Open/Close position

#### Open position

When the liquidity is staked in HedgeCat Protocol, the status 'isOpen' is true. Traders can open position based on it.

Traders need to determine the size and the deadline for the position.

The size can not exceed 100% of the liquidity. And the deadline can not exceed the deadline of liquidity.

HedgeCat Protocol calculates the margin and funding payment based on size and deadline. The position will be opened after the margin, and funding payment is completed.

#### Close position

Position can be closed in two conditions:

#### Close position on deadline:

Position can be closed by its trader at any time. In this condition, HedgeCat Protocol will redeem the liquidity. If the assets from removed liquidity are not enough, then trader's margin will be taken to make up the insufficient part, and the trader can claim the remaining margin.

#### Close expired position:

When the position had expired, anyone can close this position (trader and liquidity provider).

HedgeCat Protocol will redeem the liquidity and take margin to make up the insufficient part. The remaining part will be sent to the trader.

*(We strongly recommend traders to keep their positions not expired. Because expired positions are potentially subject to price manipulation attacks. Unrealized profit and margin may be lost in this process.)*

### Participants / User Persona

Liquidity Providers

The liquidity provider can get incentive rewards when they stake their liquidity token into HedgeCat. The reward mostly comes from the HedgeCat incentives and the funding payments paid by traders.

Traders

Traders in HedgeCat make profit when they leverage longs or short sells with target token pairs. As HedgeCat protocol supports any token-pairs in the DEX, the funding efficiency and leverage can be extremely high in some token-pairs especially when trading

*long*-*tail*assets.Market Makers

Nowadays traditional market makers who used to contribute liquidity in the digital assets of exchanges are investigating values and vision for decentralized exchanges. Although the trading volume of DEX is large enough to attract their potential, the impermanent loss is a huge problem for them because of the volatile price action of the crypto market. HedgeCat protocol provides the hedging opportunity for them to earn risk-free return. The funding payment calculated by the order size and duration from the traders is covering part of the liquidity risk posed by the price change. Furthermore, the market maker themselves can use the HedgeCat protocol to hedge the risk of offsetting the position over time.

Arbitragers

Arbitragers are the active parties in the decentralized world. The bots keep making profit with price differences between various marketplaces. However, arbitrageurs are facing risks when trading on a DEX, such as front-running and execution risk in exchange. For this scenario, arbitragers can make orders directly in HedgeCat to buy/sell target token with high leverage. This lets them amplify the profit with lower risk.

## References

[1](https://uniswap.org/whitepaper-v3.pdf)

## Disclaimer

This paper is for general information about HedgeCat only. It does not constitute investment advice or a recommendation or solicitation to buy or sell any investment and should not be used in the evaluation of the merits of making any investment decision. It should not be relied upon for accounting. Legal or tax advice or investment recommendations. This paper reflects the current opinions of the authors and is not made on behalf of Paradigm or its affiliates. New updates and changes will not be announced. Please follow the official website for the latest product updates.

Last updated