# The GammaSwap Contract: P/L, Strike Price, Time to Expiration, Delta, and Fees

In this article I’ll describe the GammaSwap contract, its P/L formula, and other characteristics of the contract that are useful to speculators and hedgers.

## Introduction

In this article I’ll describe the GammaSwap contract, its P/L formula, and other characteristics of the contract that are useful to speculators and hedgers. GammaSwap is the first oracle free, decentralized volatility trading platform, capable of handling any token pair. That is there are no intermediaries in facilitating a transaction. Costs are determined by market forces according to the parameters in its fee structure model. All the functions and formulas are derived from the research published in previous medium articles.

## GammaSwap Value Formula

As followers of GammaSwap may already know a long volatility GammaSwap position is a portfolio consisting of a short of LP tokens and a long of the underlying tokens the LP tokens represent as mentioned in the original description of the protocol. This is accomplished by borrowing the LP tokens, converting them into their underlying reserve tokens and adding adding additional reserve tokens as buffer collateral to cover interest accrued on the loan. All collateral remains inside the platform to maintain the credit health of the loan.

For example, for a long volatility position in WETH/USDC pool of 1 LP token, assuming a price of 1,500 USDC per WETH, a long volatility position looks as follows

Since the impermanent loss formula is measured as the difference between the constant held token portfolio and the LP portfolio, and the position is opened through a loan of LP tokens, his returns are going to be the opposite of a leveraged impermanent loss formula. In mathematical terms this is the position a buyer of volatility in GammaSwap is holding (if we measure their value in terms of token y)

From now on we’ll refer to x as the quantity of WETH and y as the quantity of USDC.

The combination of these two positions make up the value of the portfolio of the trader holding the position.

Since the short position is acquired as a loan of LP tokens, then as time passes the value of the position changes due to interest accruals.

We use the Euler number to assume continuous compounding, although in actuality the GammaSwap contract borrow rate compounds every time a transaction happens each block.

Remember that the value of the held portfolio can also be stated in terms of liquidity invariant units and the initial price of depositing liquidity and the value of the LP position can be stated in terms of the initial price p_0. Therefore,

Therefore, the value of the portfolio can be stated solely in terms of liquidity invariant units, the initial price and the change in price since the position was opened.

In the definition above k is the ratio between the future price, p, and the current price, p_0, which is also the price at which the position was opened (the price at which liquidity was borrowed). Through a thought exercise, if we consider the initial price as some event that happened in the past and p the current price instead of a future price, then we can define p_0 (the initial collateral ratio of the CFMM) as the strike price of a GammaSwap position. Then our final formula for the value of a GammaSwap position becomes

## GammaSwap P/L Formula

Now to calculate the P/L we need to know the value of the portfolio at the time the position was opened. That is we want to know the value of the portfolio at t = 0, a time when no interest had accrued yet. This value is also the value of the collateral buffer that absorbs losses from interest accruals and price changes.

The collateral buffer is the “Deposit” column in the trade page of app.gammaswap.com when you open a position.

If there were no market impact or trading fees associated with the transaction to rebalance collateral when opening a position, its value would be identical to the value entered in the “Add Initial Deposit” input field of the trade tool in the trade page of app.gammaswap.com.

Having the value of the position at t=0 (the collateral buffer value), we can now calculate the P/L as the change in value of the portfolio from the time it was opened to the current time. This is dependent on the evolution of the price and the accumulation of interest on the loan. Therefore, the formula for the P/L is as follows

Through some algebra the formula can be simplified as

## Collateral Ratio aka Strike Price

Since the strike price is simply the ratio of the reserve tokens in the CFMM at the time liquidity was borrowed and a liquidity borrower in GammaSwap has control over the reserve tokens collateralizing the liquidity debt, he can rebalance the reserve tokens to achieve a different strike price. The modification of the collateral ratio is what allows a liquidity borrower to change the return profile of his position.

In the trade page of app.gammaswap.com, the “Long” and “Short” tabs of the trade tool set the strike price to 2/3 and 3/2 of the current price of the CFMM when opening a long or short position respectively. Straddle positions, result in a strike price that is equivalent to the current price of the CFMM.

For example, if the CFMM price for WETH/USDC is currently 1,580. The “Long” tab will set the strike price to 1,053.33, the “Short” tab will set it to 2,370, and the “Straddle” tab will set it to 1,580.

The contract however is capable of setting any strike price a user wishes as long as they deposit enough buffer collateral to achieve the desired LTV ratio. This feature will be available in app.gammaswap.com over the coming weeks.

Liquidity borrowers should note, however, that changing the collateral ratio to a different value other than the current ratio of the CFMM results in a lower L_hat (liquidity invariant of the collateral tokens). This is a consequence of the mathematical properties of a geometric mean.

Therefore, the further away you set the strike price from the current CFMM price, the lower the expiration/liquidation time of the position, which we will cover in the next section.

## Time to Expiration/Liquidation

Since GammaSwap requires overcollateralization of liquidity borrowed, the value of L_hat (the liquidity invariant of the collateral tokens) must always be greater than L_o by a certain margin to prevent liquidation. These two values compose the LTV value seen in app.gammaswap.com when a user has an open position.

As interest accrues on L_o the LTV ratio increases driving the liquidity invariant debt to parity with the liquidity invariant collateral, at which point there is only sufficient collateral to pay the liquidity invariant debt. One can think of this scenario as the expiration time of the position. Therefore if we fix the LTV to a constant and rearrange the formula above as

We get the formula for the expiration time of the position based on the current borrow rate, collateral invariant, liquidity debt, and max LTV allowed by the GammaSwap pool. Since we made LTV a constant, this constant represents the maximum LTV allowed in the platform, e.g. the LTV threshold.

Increasing more collateral (lower LTV) increases your position’s time to expiration, giving your position more time value, but also affects your P/L formula, which is due to a change in the delta of your position, a topic we will touch in the next section.

While not possible through app.gammaswap.com yet, a liquidity borrower can always extend the life of an existing liquidity loan by depositing more collateral tokens at the same or at a different ratio than the current collateral tokens he’s holding. Of course, if providing collateral tokens at a different ratio than the one his loan is currently holding, this will change the collateral ratio of the loan. If he wishes to maintain the same ratio, the GammaSwap contract will rebalance the deposited collateral to obtain the ratio he desired. This will, however, lower the value of the collateral tokens deposited due to market impact and trading fees associated with the CFMM.

## Delta

Advanced readers with experience trading derivatives may have already realized how to calculate the delta of the GammaSwap contract. For less advanced readers, I’ll provide a description of the delta while focusing more on its uses cases in hedging and other trading strategies in a future article.

The delta is the first derivative of the value formula for a GammaSwap position with respect to price. That is how much does the value of a GammaSwap position change with every infinitesimal change in the price. This calculation is very useful in determining how much of a GammaSwap position we need to open to hedge small price changes in a larger position in the spot market.

Remember the GammaSwap value formula from above. Now we’ll add an origination fee, which we’ll talk more in the section below about dynamic origination fees.

Taking its first derivative with respect to price gives us

From the formula, one can notice the following

- Higher Strike Price => lower delta => profit from price decreases
- Lower Strike Price => higher delta=> profit from price increases
- Price up => delta up => profit more from price increases
- Price down => delta down => profit more from price decreases

The properties of the delta is what determines the non linear returns of a GammaSwap long volatility position.

The liquidity borrower does not have control over what will be the future CFMM price, interest rate, and origination fees, but at t=0, some of the variables offered to him by the market (interest rate and CFMM price) do not affect his delta. The origination fees and price of buffer collateral, however, do impact the size of the position he can open, but usually only slightly. The choice that will have the biggest impact on his delta will be the collateral ratio (strike price). Which he can always adjust at any time.

## Leverage and Hedging with Delta

One of the benefits of calculating the delta is that it tells us how much leverage we can obtain with a GammaSwap position.

For example, suppose the price of WETH/USDC is currently 1,580 USDC in the CFMM. Given the market conditions in the WETH/USDC CFMM with a 104.92 USDC initial deposit we can obtain a GammaSwap position valued at 100 USDC with a strike price of 1,053.33 USDC. The collateral invariant of this position is 31 and the liquidity borrowed to achieve the position (including origination fees of 0.1%) is 30.377. We have an LTV of 98%. At 10% interest rate, and a max LTV of 99.5% in the platform it would take 55 days for our position to reach liquidation/expiration.

Using the formula above we obtain a delta at the current price of 0.19. This means for every 1 USDC price change in WETH/USDC our 100 USDC position will gain 19 cents. That means for every 6 basis point increase in WETH/USDC our position will gain 19.08 basis points. That is a 3x increase relative to holding spot WETH without any risk of liquidation due to price variation while being capable of holding the position open for nearly 2 months.

The leverage of this position can be calculated by multiplying the delta times the CFMM spot price and dividing by the value of the position (formula for GammaSwap value of position)

That means we can use approximately a 100 USDC deposit into GammaSwap to hedge a 300 USDC portfolio for 55 days, without any risk of liquidation from price changes. Or, if you are a speculator, to more than triple the returns of small price changes in WETH if it goes up in price during those 55 days, without any risk of liquidation as with perpetual futures. After 55 days if the price did not change most of your 100 USDC deposit will have been eaten away by interest holding this position and therefore your position would be closed by a liquidator.

The GammaSwap platform can currently open positions with LTVs as high as 99.49%. Of course at that rate your position would expire very quickly. However, the same position described above but with an LTV of 99.14% would be able to replicate a WETH exposure 4x times its size with 13 days left to expiration.

## The Borrow Rate

The borrow rate for liquidity provision depends on the utilization rate of the pool according to the following formula

As the utilization rate increases the interest rate increases up to a maximum rate of 250%. The interest paid accrues to the GammaPool LPs with every transaction per block. A small percentage is paid to the protocol, currently set at 10% of interest accrued. This difference ensures that as the utilization rate increases and interest rates spike, the spread between what is borrowed to liquidity providers and charged to borrowers widens.

## Dynamic Origination Fees

Origination fees are fees paid at the start of the loan. They’re an upfront fee that is only paid once when you borrow liquidity. They are charged as a small percentage of the borrowed liquidity of the position. Therefore, it’s charged in terms of liquidity invariant units and added as part of the liquidity borrowed at the start of the loan. Therefore, a P/L formula taking into account the origination fees is as follows

The origination fees in GammaSwap are dynamic and also depend on the utilization rate of the pool. Which means as the utilization rate of the pool decreases due to demand for longing volatility increasing, the origination fees also increase according to the following formulas

The parameters are currently set so so that the origination fee starts at 10 basis points and remains at 10 basis points until the 76% utilization rate. At that point it starts growing linearly with 1 basis point per 1% point increase in the utilization rate until it reaches 91% utilization rate. At that point it starts growing exponentially until it maxes out at 100% when the utilization rate of the pool is at 99% or greater. That means you would be charged 100% of the liquidity borrowed as an origination fee. The purpose of such a high fee charge is to discourage liquidity borrowing at very high utilization rates.

The fact that the origination fee is only paid upfront as a sunk cost means that the effect of the origination fee on returns decreases as the liquidity borrower holds his position for a longer period of time.

For example, if the borrow rate is 28.32% and a liquidity borrower closes his position on the first day, having paid an origination fee of 20 basis points, this implies a total annualized cost in fees of 119.6%. If he holds it for a second day, it implies a fee cost of nearly half its size of 73.94%. Three days 58.73%, etc. This way, active traders (speculators) pay a premium for using the platform while less active traders (hedgers) benefit from lower long term costs without being severely impacted by speculator’s short term behavior.

The origination fees also accrue to LPs in the GammaPools with a percentage paid to the protocol. Which means that if enough activity occurs in the platform, the yield paid to liquidity providers can be higher than the borrow rate excluding origination fees.

The origination fee can also be set to always return 0 at which case there would be no origination fee and the P/L formula would be the same as the one stated earlier without origination fees.

## Utilization Rate Protection

To protect against manipulation of the utilization rate for the purpose of diminishing origination fees in periods of high utilization, GammaSwap uses a floor utilization rate when calculating dynamic origination fees. The floor is set through an exponential moving average that updates with every transaction and block

The value of α for the purpose of updating the EMA is determined as follows

According to the formulas above, the EMA of the utilization rate, if there are no updates to the GammaSwap pool contract, will match the current utilization rate after 100 blocks of the Ethereum network. If there are transactions happening in the GammaSwap pool contract, the EMA of the utilization rate will match the current utilization rate faster than 100 blocks.

## CFMM Trading Fees

CFMM trading fees are accrued to LPs in GammaSwap and are therefore also charged to liquidity borrowers. However, the existence of trading fees also affect the impact of rebalancing the collateral of a loan to achieve a desired collateral ratio (strike price). The CFMM trading fees therefore lower the final L_hat in the P/L formula.

## Rebalancing Collateral Market Impact

Rebalancing the collateral ratio (choosing a strike price away from current price) also affects the final collateral’s liquidity invariant due to market impact of the transaction. Lower liquidity levels in the CFMM pool mean the transaction will incur higher slippage and therefore result in a worse transaction rate to achieve the desired collateral ratio (strike price), thus lowering the L_hat (collateral invariant) in the P/L formula and resulting in a smaller initial position value than the amounts deposited. The calculation required to figure out what will be the market impact of your transaction to set a specific collateral ratio (aka strike price) requires solving a quadratic formula to determine how much to rebalance (solve for Δx) to obtain the desired collateral ratio given the current level of liquidity and trading fees in the CFMM and your current collateral amounts.

Due to the market impact opening a position can have in the underlying CFMM so that it is properly hedged by GammaSwap, the amount of collateral buffer (deposit) a liquidity borrower can purchase can be significantly less than his initial deposit in the GammaSwap user interface. Therefore, careful thought should be given to opening positions in CFMM’s with low liquidity if one seeks to rebalance the collateral ratio to a price far away from the current CFMM price.

## GammaSwap Calculator

This spreadsheet in the GammaSwap’s github repository can be used to calculate the cost of opening a position in GammaSwap with different strike prices. The cost is given as well as the delta and time to expiration given different market conditions that are defined as inputs in the spreadsheet. The inputs are in orange.

**Deposit (USDC Buffer)**- refers to the “Deposit” column when you have a position open in app.gammaSwap.com. In this spreadsheet you enter how much you want to have as collateral buffer for your position. This field refers to the “Collateral Buffer Formula” from above.**LTV**- is the Loan To Value ratio of the liquidity debt to liquidity collateral of the position. A higher LTV, the closer to liquidation it will be, therefore the less “Time to Liquidation (Days)”- Strike Price (Coll. Ratio) - refers to the collateral ratio (aka strike price) of the position you want to open. Different strike prices have different deltas as given by the formula above
**Time to Liquidation (Days)**- refers to how many days till liquidation this position will have with the given LTV.**Deposit Price**- is the price you are paying per unit of “Deposit (USDC Buffer)”. In the example above that means 1.0474 USDC per 1 USDC Deposit.**Initial Deposit (USDC)**- refers to how much you’ll have to deposit in the “Initial Deposit” input box of the trade page of app.gammaswap.com. This means to get a 100 USDC Deposit you have to deposit 104.74 USDC.**Delta**- is the change in value of the position per every 1 USDC change in the price of the volatile asset (in this case WETH). In the example above that’s 25 cents per every 1 USDC price change in WETH. The delta increases as the price of WETH increases.**Leverage**- is how much leverage you are getting opening this position. In the example, it’s 4x. Therefore opening this position with a collateral buffer of 100 USDC (Deposit (USDC Buffer)), is the same as having an ETH position worth 399.68 USDC.**Size (USDC)**- refers to the leveraged size of the position (100 x 4 ~ 399.68)**ETH Price in USDC**- in the “Post Trade” section refers to the price of ETH after opening a position with a 100 USDC buffer.**Price Impact**- in the “Post Trade” section refers to how much the price was moved by the opening of the position. In the example above opening the position moved the price of ETH 2 basis points. The inputs for the CFMM and GammaSwap are given below

**Current ETH Price (USDC)**- refers to the current price of ETH in terms of USDC in the CFMM.**Liquidity Invariant**- is the geometric mean, i.e. sqrt(X*Y), of the reserve assets (ETH and USDC) inside the CFMM**Fee**- is the trading fee charged by the CFMM**ETH in CFMM**and**USDC in CFMM**is how much ETH and USDC is in the CFMM given the “Liquidity Invariant” and “Current ETH Price” inputs

**Borrow Rate**- is the rate per year charged by GammaSwap to liquidity borrowers (buyers of volatility) including the trading fees in the CFMM. This is a variable number but can be averaged over periods of time to get a fair estimate of expected costs.**Max LTV**- refer sto the maximum LTV allowed by the GammaSwap pool before a liquidity loan goes is subject to liquidation (is expired).**Origination Fee**- refers to the origination fee charged by the GammaSwap pool at the current time. This is also variable, depending on the utilization rate of the pool but it is only paid once, up front when opening a liquidity loan.

**Px Change**- column is how much the price of the underlying asset in the CFMM has changed.**Price (USD)**- is the price of the volatile asset**Pos Size (USD)**- is the value of the position in USD terms**P/L %**- is the profit and loss in percentage terms of the position as the price of the volatile asset changes**P/L (USD)**- is the profit and loss of the position as the price changes**Delta**- is the delta of the position as the price changes. A GammaSwap position is a volatility trade, therefore the delta will increase as the price of the asset increases. The returns are therefore nonlinear and the P/L will grow faster than linear.**Leverage**- is the leverage the position represents as the price changes. Leverage as in relative to how much was the collateral buffer (Deposit) used to open the position.

We’ll be incorporating more of the features from the calculator spreadsheet over the coming days into app.gammaswap.com while adding more information useful to speculators and hedgers to the spreadsheet in our github repository.

# Conclusion

In this article I described the P/L formula for the GammaSwap contract. I also described the factors affecting the P/L such as the strike price and the time to expiration/liquidation. I also explained the costs affecting the loan such as the borrow rate, the origination fees, and the CFMM trading fees and market impact when setting a strike price. I also provided a spreadsheet to calculate the P/L, delta, leverage, time to liquidation, and cost in collateral to deposit to open a GammaSwap long volatility position. In the next article I’ll cover the Greeks of the contract and some trading and hedging strategies.