# Squeeth implementation guide
Squeeth is a perpetual that enables traders to capture asymmetric upside from its option-like convexity.
## Gamma Transform
Building on top of Panoptic allows us to construct virtually any exotic payoff as "multi-legged" XPO. To accurately replicate a Squeeth position into these four legs, we use the gamma transform method described by Lambert.
1. Compute r0 = r^(1/N) from the range factor
2. Compute (k0, k1, k2, …, kN) = (K/r*r0, K/r*r0³, K/r*r0⁵, K/r*r0^7), that’s the location of each position
3. Deploy N Uni v3 LP positions centered around (k0, k1, k2, k4), where the size of the position at “j” is 2*kj*(r0²-1)/r0.
By having a single range for users to provision liquidity too, we can simplify liquidity provisioning for Squeeth.
## Pricing
Besides the swap fees from Uniswap subsidizing liquidity providers who are short gamma in Panoptic, building on top of Panoptic enables the cost of borrowing LP share liquidity to be more consistent.
// TODO: Add simulations
## Calculations
**Squeeth**: constant gamma 2
Price of ETH = 1,575.39 USDC
$P_{a} = 1400$ USDC
$P_{b} = 1800$ USDC
---
The strike is K=√(priceUpper*priceLower):
$K = \sqrt{1400*1800}$
$K = 2,520,000$
$K = 1587.4508$
---
r = √(priceUpper/ priceLower) is the range factor:
$r = \sqrt{1800/1400}$
$r = 1.1339$
---
The width of the gamma basis, $r_{0}$:
$r_{0} = r^{1/N}$
$r_{0} = 1.1339^{1/4}$
$r_{0} = 1.0319$
---
The locations for each leg would be at, $K_{0}, K_{1}, K_{2}, K_{3}$. Computed by $K/r*r0^{2N-1}$.
$K_{0}$ exp = $(2*1) - 1 = 1$
$K_{1}$ exp = $(2*2) - 1 = 3$
$K_{2}$ exp = $(2*3) - 1 = 5$
$K_{3}$ exp = $(2*4) - 1 = 7$
---
$K_{0} = K/r*r_{0}$
$K_{0} = 1587.4508/(1.1339*1.0319)$
$K_{0} =$ **1356.7127**
---
$K_{1} = K/r*r_{0}^3$
$K_{1} = 1587.4508/(1.1339*1.0319^3)$
$K_{1} = 1587.4508/(1.1339*1.0988)$
$K_{1} =$ **1274.1098**
---
$K_{2} = K/r*r_{0}^5$
$K_{2} = 1587.4508/(1.1339*1.0319^5)$
$K_{2} = 1587.4508/(1.3266)$
$K_{2} =$ **1196.6311**
---
$K_{3} = K/r*r_{0}^5$
$K_{3} = 1587.4508/(1.1339*1.0319^7)$
$K_{3} = 1587.4508/(1.4126)$
$K_{3} =$ **1123.7794**
---
Finally to achieve a gamma of 2 for the combination of legs, the size of each position must be equal to $2*kj*(r0²-1)/r0$.
$K_{0}$ = $2*k_{0}*(r0²-1)/r0$
$K_{0}$ = $2*1356.7127*((1.0319^2)-1)/1.0319$
$K_{0}$ = $2713.4254*(0.0648/1.0319)$
$K_{0}$ = $2713.4254*0.0627$
$SIZE$ at $K_{0}$ = **170.1318**
---
$K_{1}$ = $2*k_{1}*(r0²-1)/r0$
$K_{1}$ = $2*1274.1098*((1.0319^2)-1)/1.0319$
$K_{1}$ = $2548.2196*(0.0648/1.0319)$
$K_{1}$ = $2548.2196*0.0627$
$SIZE$ at $K_{1}$ = **159.7734**
---
$K_{2}$ = $2*k_{2}*(r0²-1)/r0$
$K_{2}$ = $2*1196.6311*((1.0319^2)-1)/1.0319$
$K_{2}$ = $2393.2622*(0.0648/1.0319)$
$K_{2}$ = $2393.2622*0.0627$
$SIZE$ at $K_{2}$ = **150.0575**
---
$K_{3}$ = $2*k_{3}*(r0²-1)/r0$
$K_{3}$ = $2*1123.7794*((1.0319^2)-1)/1.0319$
$K_{3}$ = $2247.5588*(0.0648/1.0319)$
$K_{3}$ = $2247.5588*0.0627$
$SIZE$ at $K_{3}$ = **140.9219**
-203575 63
-202945 63
-202315 63
-201685 63
## Parameters
A squeeth position is a single deployed instance of the Panoptic Protocol containing:
* One `PanopticPool` containing all core logic.
* Two `CollateralTrackers`, one for each constituent `token0` and `token1` in the Uniswap pool
* The `SFPM` to manage liquidity across every Panoptic Pool
The `PanopticHelper.sol` contract shows the parameters for muiltiple option strategies. For Squeeth, the parameters are simpler we use all four legs.
The `_optionRatio` is the size of one leg relative another, so the value the ratio of SIZE at $Kj_{a}/Kj_{b}$?
The first leg, legIndex = 0 will have the following parameters:
```
.addLeg({
legIndex: 0,
_optionRatio: 1,
_asset: 1,
_isLong: 0,
_tokenType: 1,
_riskPartner: 0,
_strike: 1357,
_width: 40
```
The second leg, legIndex = 1:
```
.addLeg({
legIndex: 1,
_optionRatio: 1,
_asset: 1,
_isLong: 0,
_tokenType: 1,
_riskPartner: 0,
_strike: 1600,
_width: 40
```
The third leg, legIndex = 2:
```
.addLeg({
legIndex: 3,
_optionRatio: 1,
_asset: 1,
_isLong: 0,
_tokenType: 1,
_riskPartner: 0,
_strike: 1196,
_width: 40
```
The fourth leg, legIndex = 3:
```
.addLeg({
legIndex: 3,
_optionRatio: 1,
_asset: 1,
_isLong: 0,
_tokenType: 1,
_riskPartner: 0,
_strike: 1600,
_width: 40
```
Then we can mint Squeeth!
```
pp.mintOptions({
positionIdList: positionIdList,
positionSize: 10 * 10 ** 18,
effectiveLiquidityLimitX32: 0,
tickLimitLow: 1400,
tickLimitHigh: 1800
});
```