Gamma Swap by Deri Protocol
Introduction
In the previous paper, we introduced a new type of derivative, Gamma Swap. As discussed, the trading of Gamma swap depends on a composite trading venue consisting of two (virtual) primitive trading venues for power perps and perpetual futures. This paper explains the implementation of such a composite trading venue by the DPMM of Deri Protocol.
Composite DPMM of Gamma Swap
Following the terminology in the previous paper, in this paper, refers to the index price while refers to the different kinds of mark prices. The core role of DPMM is to determine the mark prices based on the index price input and the trading activities. Everything else (e.g., PnL, funding fees) is then based on the mark prices.
Internally, 1 unit of Gamma swap is treated as a portfolio of powers and perps. DPMM simultaneously keeps track of the power and perp positions and calculates their respective mark prices. When 1 unit of long Gamma swap is entered, the DPMM adds 1 unit of power and units of perp to the two positions, respectively. One could also enter a Gamma swap position with a specified entry price . In that case, DPMM would add 1 unit of power and units of perp to the two positions, respectively. Denote the total net position of power as and total net position of perp as , then DPMM calculates the mark price of perp as follows:
where is the index price of the underlying, and . Please note that:
This is just the classical DPMM for perp with as the total net position, instead of just .
Notice that at a “balanced point”, at which the liquidity pool has no Delta exposure. For example, immediately after the first position was opened, we have and , hence . A “balanced point” is equivalent to the scenario of zero net position in a regular DPMM of perp.
A trading action reducing (and thus bringing the system to the “balanced point”) enjoys a negative slippage of . However, since opening a new position at the current price (without specifying entry price) does not change , it does not enjoy a negative slippage. This is a bit different from the case of perp DPMM, in which a new position reducing the total net position always enjoys negative slippage.
And the mark price of power is:
where is the theoretical price of the power, calculated just like that in the power perp DPMM:
Now we have a composite DPMM that, at any point, takes the state variables to determine and hence gives as
determines the trading cost of every trade and consequently determines PnL.
Funding Calculation
1 unit of Gamma swap has composite funding based on the power funding and the perp funding:
where are the as of the position entry point, and
is simply handled the same way as power perps.
Whereas the handling of is somewhat tricky, as the coefficient of the term is constantly changing with . Essentially, this can be understood as every unit of Gamma swap has “real futures” as well as “virtual futures”, and hence totally effective futures. The tricky part is the constantly varying virtual part. Because of this constantly varying virtual part, the perp funding should be calculated per Gamma swap, instead of per futures.
By definition, the exact funding fee of 1 unit of Gamma swap accumulated over the time period should be the integral of over this period.
where and are the accumulated increment of and over :
Please note that the two accumulating variables and are universal to all positions while is position-specific. We need to track the accumulations of and separately and then for any position we can calculate its accumulated funding fee with its own value of . That is, for a position of gamma swaps entered at with entry values , its accumulated funding fee from to is:
In practice, it is impossible to rigorously calculate and due to their path-dependencies. Hence, we need some numerical approximations.
Approximation Method 1
We assume the funding over the time period is accumulated at the speed as of . Essentially this assumes . With this approximation, the two integrals over degenerate into simple multiplications:
Approximation Method 2
A more reasonable approximation is to assume the index price changes linearly over :
Then we can calculate the accumulating variables and as follows:
where , and are the time-weighted average value of , and over , respectively:
With this approximation, the power funding component can be calculated similarly:
where is the accumulating variable tracking the accumulation of power funding. In practice, the two variables of power and futures can be combined into a single variable.
Summary
The previous paper introduces the concept of Gamma Swap, a new type of derivative depending on a composite trading venue consisting of two primitive trading venues for power perps and perpetual futures. This paper explains the implementation of such a composite trading venue by the DPMM of Deri Protocol. With the DPMM for Gamma Swap constructed, now we are ready to roll out a comprehensive solution for Gamm Swap.
Last updated