**1) Range Compression AMM** NFTPerp V2 uses a mechanism for concentrating liquidity that achives results similar to Uni V3 concentration using a much simpler and easier-to-modify mechanism. Our simulations, which you can find [here](https://colab.research.google.com/drive/1wy8yx50KNe1Rfgvh6KW-cXYUKcMyuMt_?usp=sharing), shows that this achieves the same output for a given input as a Uni V3 Liquidity pool ![Range](https://hackmd.io/_uploads/rkg5vegwT.png) Range Compression AMM begins like any other AMM with X and Y reserves. The upper and lower bounds of the range are constants and stored as an square root called square root alpha and square root beta Instead of k = XY in Uni V2, this mechanism uses $(X + m)(Y + n) = L^2 — (i)$ Where m and n are constants, L is an invariant that stays the same after a trade. m and n must be set so the curve is bounded with the range stored in alpha and beta. This demands: $m = \frac{L}{\sqrt{\beta}}— (ii)$ $n = L \cdot \sqrt{\alpha} — (ii)$ Combining (i) and (ii) we get a quadratic equation: $(1 - \frac{\sqrt{\alpha}}{\sqrt{\beta}})L^2 - (\frac{y}{\sqrt{\beta}} + x\sqrt{\alpha})L - xy = 0$ Using Quadric Formula, we calculate L as follows: $a = \left(1 - \frac{\sqrt{\alpha}}{\sqrt{\beta}}\right)$ $b = \left(\frac{Y}{\sqrt{\beta}} + X \cdot \sqrt{\alpha}\right)$ $c = (X \cdot Y)$ $L = \frac{-b \pm \sqrt{(b \cdot b + 4 \cdot a \cdot c)}}{2 \cdot a}$ With this, the Virtual Reserves are calculated using (ii), and output for a given input is calculated the same as in Uni V2 but with X as X + m and Y as Y + n. 2-GLP inspired this math and more can be found about it in its technical specification and mathematics [here](https://docs.gyro.finance/gyroscope-protocol/technical-documents). We have also created a desmos to go about this step by step [here](https://www.desmos.com/calculator/hmlnc6n1rv).