# How to Profit from Volatility with GammaSwap

In this article, I will describe how to borrow liquidity from GammaSwap using the web interface and what each of the parameters in the web interface mean.

## Introduction

GammaSwap is a set of smart contracts to allow users to borrow liquidity from Automated Market Makers (AMMs), specifically Constant Product Market Makers (CPMMs), to turn the infamous impermanent loss into an impermanent gain for liquidity borrowers. Therefore, GammaSwap allows AMM participants to profit from price variation.

In this article, I will describe how to borrow liquidity from GammaSwap using the web interface and what each of the parameters in the web interface mean.

## Background on Borrowing Liquidity

When someone borrows liquidity in GammaSwap, LP tokens from lenders are burned. The amount of LP tokens burned, in other words the debt, is measured in Liquidity Invariant Units (LIU) of the AMM. In the case of DeltaSwap (GammSwap’s feeless spot DEX), that is the geometric mean of the reserve tokens borrowed from the AMM.

When the LP tokens are burned, the collateral remains in the GammaSwap smart contract — it cannot be custodied by the user like other lending platforms (Aave, Radiant, etc).

If the price of the AMM changes, the funds withdrawn and held constant as collateral backing the liquidity loan from the AMM become more valuable relative to the liquidity borrowed from the AMM. This difference is the profit of liquidity borrowers, which is commonly known as impermanent loss but now turned into an impermanent gain to liquidity borrowers.

## Trade Strategies

There are three trade strategies to borrow liquidity in GammaSwap: the Straddle, the Long and the Short. Each strategy can be selected through its individual tab in the trade page of app.gammaswap.com.

## The Straddle Position

The Straddle has an initial delta of 0 meaning that this position starts as delta neutral in terms of the the quote token of the pool. For example in the WETH/USDC pool, the position is delta neutral in terms of USDC. Therefore, the position gains value if the price of WETH increases or decreases relative to USDC. However, in order for the price change to result in a positive P/L to the liquidity borrower, the gains have to offset the opening costs and interest accrued on the loan.

The Straddle has a lower cost to open than the Long or Short trade positions because it does not require the rebalancing of any collateral. It is borrowed in the canonical 50:50 ratio.

A Straddle is ideal for a market participant that has no opinion on the direction of the market but expects a large price movement. It is also a position better suited for low liquidity pools as it has no rebalancing requirements and therefore won’t suffer from rebalancing slippage when opening the position.

Lastly, it is also a perfect hedge for a full range LP position because the delta matches exactly the LP position’s delta.

All long volatility positions in GammaSwap have a dynamic delta, unlike a perpetual future where the delta is fixed. What that means is that as the delta increases, the leverage of the position also increases. However, one must not confuse a GammaSwap long volatility position as an ideal substitute for a perpetual future. Since the incremental leverage implies that the position will be more difficult to close without significant slippage if the price has deviated substantially. However, it can certainly be used to replicate the returns of perpetual futures by matching the delta of a perpetual futures position and rebalancing the collateral as the price changes to maintain the same delta exposure. This strategy would be similar to attempting to capitalize on the Loss vs Rebalancing metric popularized by Tim Roughgarden while maintaining a biased view of the market.

## The Long Position

The Long position is a Straddle position whose collateral has been rebalanced to a ratio of 2/3 of the current price. Therefore a Long position is a Straddle position with a strike price that is 2/3 of the current market price. What that essentially means is that the put part of the Straddle is out of the money and the call part of the Straddle is deep in the money. Therefore, such a position behaves more like a deep in-the-money call option. It gains value faster as the price in the AMM rises and loses value as the price in the AMM declines because the position starts with a positive delta.

If the funds retrieved from a borrowing and burning an LP tokens is 1000 USDC and 0.5 WETH, implying a price of 2,000 USDC per WETH, then assuming no slippage or trading fees, the position would be rebalanced to 800 USDC and 0.6 WETH. That is 200 USDC was used to purchase 0.1 WETH at 2,000 USDC per WETH. The new collateral ratio of the loan, or strike price, is now 1,333 USDC (800 USDC / 0.6 WETH).

Due to the position having a positive delta, it already starts as a leveraged position to take advantage of smaller price movements. However, it is also more expensive to open due to the slippage and trading fees from rebalancing the collateral withdrawn from the AMM. The maximum initial leverage the position can be opened through the web interface is around 4.2x.

A Long position is ideal for liquidity borrowers that have a bullish view on the market. They expect a large price move to the upside but do not wish to be liquidated from an adverse price movement. Since this position is actually also a Straddle position, when the price moves against the liquidity borrower they will suffer a loss until the strike price is reached, at which point the P/L will increase again as the price continues to decline.

The position is not capable of being liquidated due to price declines, only through debt incurred from the borrowing rate. Therefore, all trade positions in GammaSwap do not have a liquidation price. Instead there is a Time to Liquidation metric which is based on the LTV of the position and the current Borrow Rate.

## The Short Position

The Short position is a Straddle position whose collateral has been rebalanced to a ratio of 3/2 of the current price, and therefore follows the inverse logic described in the Long position.

If the funds retrieved from a borrowed and burned LP tokens is 1000 USDC and 0.5 WETH, implying a price of 2,000 USDC per WETH, then assuming no slippage or trading fees, the position would be rebalanced to 1,200 USDC and 0.4 WETH. That is 0.1 WETH was sold for 200 USDC at a price of 2,000 USDC per WETH. The new collateral ratio of the loan, or strike price, is now 3,000 USDC (1,200 USDC / 0.4 WETH).

This collateral ratio is achieved by rebalancing the collateral with the AMM and therefore is susceptible to high slippage costs in low liquidity pools plus trading fees. Just like the Long position, as the price moves against the liquidity borrower, he will suffer losses until the price crosses the strike at which it will be profitable again. The max initial leverage is around 3.2x when using the web interface.

## How to Borrow Liquidity

Navigate to the Trade Button in the header of the application and click the Borrow Tab. You can select the pool you would like to borrow liquidity from using the Pool Selector. Borrow Page in Trade section

Once you have selected the pool you would like to borrow liquidity from, you need to decide your trade strategy — Straddle, Long, or Short — and adjust your input parameters accordingly.

## Inputs for Borrowing

## Initial Deposit

This is the amount deposited to over-collateralize the position, described in the GammaSwap article here.

Remember that the debt in GammaSwap is measured in Liquidity Invariant Units (LIUs), which can be found by calculating the square root of the product of the total borrowed token quantities from the AMM. For example, if borrowing from the WETH/USDC pool, one would perform the following calculation to find the debt in LIUs.

Debt in LIUs= sqrt(borrowed_WETH * borrowed_USDC)

Collateral in GammaSwap is also measured in terms of LIUs. Since a user borrows the reserve tokens when he or she initiates a loan, the reserve tokens themselves fully collateralize the loan. However, in order for the loan to remain open as it accrues interest it must be overcollateralized. Therefore, the liquidity borrower must deposit an additional amount of collateral as one or both of the tokens to overcollateralize the loan.

Thus the total collateral value of the loan can be measured with the following formula.

Collateral in LIUs = sqrt[(Initial Deposit of WETH + borrowed_WETH) * borrowed_USDC]

or if depositing USDC

Collateral in LIUs = sqrt[(Initial Deposit of USDC + borrowed_USDC) * borrowed_WETH]

or if depositing both tokens at the same time

Collateral in LIUs = sqrt[(Initial Deposit of USDC + borrowed_USDC) * (borrowed_WETH + Initial Deposit of WETH)]

Depositing both tokens at the same time to overcollateralize a loan is currently not possible through the web interface but it can be achieved programmatically.

Converting any of the LIU numbers to either token1 or token0 of the pool can be achieved with the following formula

LIUs in Token1 = 2 * LIUs * sqrt(Price In Token1)

or

LIUs in Token0 = 2 * LIUs * sqrt(Price In Token0)

For example, in the case of WETH/USDC, assuming WETH is equal to 2,800 USDC, the debt in LIUs is equal to 95 an the collateral in LIUs is equal to 100, finding the value of the debt and collateral in USDC would be achieved with the following formula

Debt in USDC = 2 * 95 * sqrt(2,800) = 10,053.85 USDC

Collateral in USDC = 2 * 100 * sqrt(2,800) = 10,583.01 USDC

## Loan to Value (LTV)

The LTV is the proportion of debt to collateral in the liquidity loan measured using the previous formulas for debt and collateral as input parameters in the following formula

LTV = Debt / Collateral

You can think of the LTV as choosing the expiration date of your option. The higher the LTV (the sooner your position will expire through liquidation), the more leveraged your position is.

For example, assume the liquidation threshold is 99.5% and the current annualized Borrow Rate in the pool is 10%. A user opens a loan with a 99% LTV, so assuming debt compounds continuously, the relationship between the liquidation threshold and debt of the loan is the following

LTV_Liquidation_Threshold = Debt * e^(r*t) / Collateral

which can also be stated as

LTV_Liquidation_Threshold = LTV * e^(r*t)

where e is the Euler number, t is the time in years, and r is the annualized Borrow Rate. Plugging in the values from before we get

99.5% = 99% * e^(0.1 * t)

Since we assumed the Borrow Rate is 10%, then the only unknown is t. Therefore, solving for t gives the following

99.5% = 99% * e^(0.1 * t) → t = ln(99.5% / 99%) / 0.1 ~ 0.05038

converting from years to days we get

days = t * 365 = 0.05038 * 365 = 18.39

It will take 18.39 days till this loan reaches the liquidation threshold at a Borrow Rate of 10%, given that it is starting with an LTV of 99%. Therefore the Borrow Rate and chosen LTV is what determines the lifespan of the liquidity loan.

A user can choose their LTV using the sliding scale. A user can choose an LTV from 97% to 99.3% through the web interface. The max level of overcollateralization is 99.5%, which is the current liquidation threshold in all GammaPools.

When a loan crosses the 99.5% LTV threshold, it is subject to liquidation.

## Trade Details

Now, we will dive deep into all of the details of the trade based on the Initial Deposit and chosen LTV.

## Time to Liquidation

This is the time it will take for the loan to cross the 99.5% liquidation threshold given the current Borrow Rate.

Time_to_Liquidation_in_Days = [ln(99.5%/LTV)/Borrow_APR] * 365

As the opening LTV increases, the Time to Liquidation will decrease.

You can think of the Time to Liquidation, as an option’s expiry. With a shorter expiration, you have more leverage but lower likelihood of your position achieving profitability.

## Borrow Amount

This the amount of Liquidity Invariant Units (LIUs) that will be borrowed from the AMM at the chosen LTV and Initial Deposit amount.

GammaSwap measures the debt of the loan in terms of liquidity invariant units (the square root of the product in the x*y=k formula). The debt in LIUs is the actual size of the loan.

As the the Initial Deposit amount increases, the Borrow Amount will increase, since more liquidity has to be borrowed to achieve the same LTV.

The choice of trade position also affects the Borrow Amount since rebalancing collateral to a ratio other than the current market price of the AMM lowers the LIU value of that collateral.

Therefore, you will always be able to borrow more liquidity with a Straddle than a Long or Short position.

## Opening Cost

The Opening Cost is the expected cost in percentage terms of the Initial Deposit used to create a liquidity loan.

It is made up of three components: origination fees, slippage, and trading fees.

Origination fees — These are fees charged on the Borrow Amount when the pool’s utilization ratio reaches a very high number (e.g. 90% for WETH/USDC), to incentivize more liquidity provisioning and discourage borrowing.

The utilization ratio thresholds at which point origination fees start being charged varies by pool according to the pool’s parameters, but it grows exponentially after a certain point as the liquidity available for borrowing in a pool runs out. The origination fee model parameters are subject to change over time as the product matures to reach an adequate utilization ratio.

Slippage — This refers to price differences a liquidity borrower gets when rebalancing collateral as compared to the price in the AMM prior to rebalancing collateral. As liquidity is borrowed out of GammaSwap, the liquidity in the underlying CFMM drops meaning that rebalancing collateral will incur more slippage. As a consequence of this the more collateral you want to rebalance to maximize your delta exposure using a Long or Short strategy, the higher the cost you will incur to achieve such a position from slippage.

Trading Fees — These are fees paid to the AMM by GammaSwap for rebalancing the collateral. DeltaSwap is a feeless DEX for traders of spot tokens but GammaSwap always pays a fee to DeltaSwap when it rebalances collateral. The fees are subject to change as pricing within the platform is better understood to remain competitive.

As a consequence of having to rebalance collateral to create a Long or Short position, Straddles are cheaper to open because they have less rebalancing costs in terms of slippage and trading fees.

## Borrow Rate

This is the expected interest rate per hour that the position will start paying once it is opened.

The Borrow Rate increases with the LTV and Initial Deposit, since the notional amount borrowed is increasing. A large borrow position increases the utilization ratio, which in turn increases the Borrow Rate.

Therefore, a larger position will reduce the Time to Liquidation since a higher Borrow Rate means the faster an LTV will approach the liquidation threshold of 99.5%.

The cost of borrowing is reflected in the P/L of the loan as a continuous cost.

## Theta

This is the daily cost in terms of the quote token, e.g. USDC in WETH/USDC, to hold a position.

The Theta is dependent on the Borrow Rate. The way it’s calculated is by multiplying the daily Borrow Rate by the Borrow Amount. Since the Borrow Rate is shown per hour, we have to convert it to a daily value by multiplying it by 24.

Theta in LIUs = Borrow Amount * Borrow Rate * 24

Since the Borrow Amount is measured in terms of LIUs, this is converted to the quote token using the following formula

Theta in Token1 = Theta in LIUs * 2 * sqrt(Price in Token1)

For example, in the case of the WETH/USDC pool, assuming a price for WETH of 2,800 USDC, the full calculation for the theta in terms of USDC would be the following

Theta in USDC = Borrow Amount in LIUs * (Borrow Rate * 24) * 2 * sqrt(2,800)

Since the theta is actually measured in LIUs its value will increase or decrease with the price of the base token (e.g. WETH in the WETH/USDC pool).

However, that doesn’t mean that the time you can hold a position open — Time to Liquidation — decreases or increases as the price of the base token goes up or down respectively. That is because your collateral is also measured in terms of LIUs and as the price increases or decreases your collateral value also goes up and down respectively. Therefore, the only determinant of how long you can hold a position is the Borrow Rate.

Nevertheless, the Theta can be useful to visualize the daily cost to hold a position open, and more indicative of total expenses over a certain period of time when prices are relatively unchanged.

## Delta

The Delta is how much the position will increase in value as the price in the pool changes, denominated in units of the quote token. The quote token is the second token in the pool, in the case of WETH/USDC it is USDC.

The Delta increases as the notional position size increases, determined by the LTV and Initial Deposit amount. A position with a higher LTV or larger deposit will have a higher delta exposure in absolute terms.

Delta can be positive or negative however depending on price direction.

As the price increases, the delta value increases and becomes more positive. As the price decreases, the delta value decreases and becomes more negative.

The Straddle position starts with a delta of zero because it is a delta neutral position. As the price goes down its delta becomes negative meaning, it starts gaining value as the price goes down. As the price goes up its delta becomes positive, meaning it starts gaining value as the price goes up.

## Leverage

Leverage refers to the amount of directional leverage a liquidity borrower gets on his Initial Deposit with the choice of a position.

The Leverage number is the same regardless of the position size, it is solely determined by the chosen LTV.

In GammaSwap, the higher the chosen LTV, the higher the leverage. This is true across all position strategies: Straddle, Long and Short.

The formula to calculate leverage is the following

Leverage = abs(Delta * AMM_Price / Initial_Deposit)

Given that the formula above is measuring the leverage based on the Initial Deposit after transaction costs the Leverage value prior to opening a position can seem higher than it really is in low liquidity pools due to high opening costs. The normal maximum leverage when opening a position is around 4.2x for Long positions and 3.2x for Short positions. If the Leverage calculation appears significantly higher than these numbers in the web interface, it’s because of high expected opening costs.

Since Straddle positions, have a delta of zero, we do not show the Leverage calculation. However, as the delta of the position becomes more negative or positive due to the price changing, its leverage will also increase.

Higher leverage amounts can be achieved programmatically but at a higher risk of liquidation.

Given the consideration of opening costs in low liquidity pools for Long and Short positions, it is recommended to use Straddles in low liquidity pools to avoid excessive slippage costs during rebalancing.

## Slippage

When trading on GammaSwap, it’s important to be aware of potential market shifts that can occur.

For instance, the price set by the AMM might fluctuate rapidly, the pool’s utilization rate might increase dramatically, etc. all after the transaction has been sent to the blockchain.

These unforeseen changes can lead to your position being different from what you anticipated or incurring higher costs than expected.

Such discrepancies between the expected and actual transaction outcomes are referred to as “implementation shortfall” or more commonly as “slippage”.

To protect liquidity borrowers, GammaSwap has implemented a robust set of slippage settings detailed below.

## Slippage Settings

To access slippage settings, click on the gear icon in the top right hand corner of the trade tool.

Automatic Slippage Tolerance — Limit the AMM price fluctuations when borrowing liquidity. This setting is meant to prevent opening a position with an entry price that is significantly different than the current price. For example, choosing 0.5% means you are willing to tolerate a 0.5% price deviation in the AMM from the time you send the transaction to the market.

Automatic Rebalancing Slippage Tolerance — Limit market impact from rebalancing collateral when opening a Long or Short position. This slippage setting also applies to closing Long and Short positions, as well as Straddles if the position is profitable or seeking to withdraw the Initial Deposit in terms of the base token (e.g. WETH in the WETH/USDC pool). In a Long or Short position, GammaSwap rebalances the collateral to achieve the necessary collateral ratio, either in a 2/3 or 3/2 ratio depending on price direction. The rebalancing slippage parameter is meant to control the slippage — the difference between your rebalancing execution price and price you saw in the screen — of rebalancing the collateral in the AMM. This situation is even more relevant in pools with low amounts of liquidity where rebalancing collateral may incur significant slippage, diminishing the returns of your positions. A solution to rebalance collateral with external liquidity sources to reduce slippage will be provided soon, however, it is still imperative to understand and use this setting especially if liquidity across all market venues is low.

Automatic Fee Tolerance — Limit unexpected origination fee charges, due to high utilization rates in the pool, when borrowing liquidity. GammaSwap’s origination fees are dynamic and although they may start at 0% they can grow significantly as the utilization rate of a pool starts hitting high levels, such as greater than 90%. Therefore, this setting prevents a borrower from paying an unexpected origination fee percentage, when the pool’s utilization rate rises unexpectedly.

## Liquidations

Once the LTV crosses the 99.5% threshold, it is subject to liquidation, where the liquidator will earn a reward equivalent to 0.25% of the collateral in LIU terms.

If a loan is liquidated, the remaining collateral can be withdrawn by the borrower through the “Borrowed” section of the Portfolio page.

Once in the “Borrowed” section click “View History” on the top right corner. You will then see a list of your closed and liquidated positions

The collateral from liquidated positions can be withdrawn by clicking on the “withdraw collateral” button.

If the position had been profitable and the profit was higher than the liquidation fee, then the liquidity borrower will be able to claim his profit by withdrawing the remaining collateral after liquidation.

For example the first position above that was liquidated ended up with a collateral available for withdrawal of 0.002 WBTC and 123.63 USDC after paying the liquidation fee.

This same position had been opened with only a deposit of 100 USDC. Therefore, even though it was liquidated, there was a remaining collateral of 123.63 USDC and 0.002 WBTC. Since WBTC was priced at around 45,000 USDC at the time, the total collateral available to withdraw was approximately 213.63 USDC. Therefore, a profit of 113.63 USDC despite liquidation.

If the liquidity borrower had closed his position before liquidation, his profit would’ve been 155 USDC. That means the amount of profit lost as payment to the liquidator was about 41.37 USDC.

## Conclusion

In this article, I’ve detailed the process of borrowing liquidity from GammaSwap to profit off Impermanent Gain, as well as ways to take leveraged directional positions. I’ve described the various input parameters found in the trade page of the web interface, clarifying the function of each parameter and how it influences the eventual position you’ll open. Additionally, I’ve explained how different input choices affect transaction costs and how they are displayed in the trade page. In the next article, I will delve into some basic hedging and arbitrage strategies that can be implemented with GammaSwap.