# IMM Functions

### IMM Conservation Functions

A scenario representing a trader buying from the pool:

<div align="center"><img src="https://976579298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftor5sd7sW1BdSm5MKyoe%2Fuploads%2FwOUy23QmGRK6fJNCcleX%2Fimage.png?alt=media&#x26;token=20f1bd96-7799-472a-b416-6918b14e0237" alt=""></div>

A scenario representing a trader selling to the pool:

<div align="center"><img src="https://976579298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftor5sd7sW1BdSm5MKyoe%2Fuploads%2FoYuX1rj2NZ3c9fnzvsDc%2Fimage.png?alt=media&#x26;token=0bdfaf11-abfe-4f0e-82ea-b0c406f14b3f" alt=""></div>

The conservation functions implicitly affect the “bonding curve”, which is continuous, differentiable, convex, and monotonically decreasing.

If the trader exchanges ΔY units of ETH to ΔX units of LP token (buys X), the pool will consist of X = Xc- ΔX and Y = Yc+ ΔY units correspondingly after the trade and the effective price of the buy trade will be:

<div align="center"><img src="https://976579298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftor5sd7sW1BdSm5MKyoe%2Fuploads%2FWeYMFGdVL2DOU7mkT1pi%2Fimage.png?alt=media&#x26;token=fa8b265a-5f44-474c-a42d-00ccd85c91cb" alt=""></div>

Similarly, if the trader exchanges ΔX units of LP token to ΔY units of ETH (sells X), the pool will consist of X = Xc+ ΔX and Y = Yc- ΔY units correspondingly after the trade and the effective price of the sale deal will be:

<div align="center"><img src="https://976579298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftor5sd7sW1BdSm5MKyoe%2Fuploads%2FHwkLyQR46vW4f66kXFYS%2Fimage.png?alt=media&#x26;token=68fcba85-3ef6-42f5-b95d-ba08a175bb87" alt=""></div>

### IMM Price Functions

The IMM price function is derived from the IMM conservation function as follows:\
\
Price as the function of ΔX:

<div align="center"><img src="https://976579298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftor5sd7sW1BdSm5MKyoe%2Fuploads%2FHKennoKyynTIrG8xje12%2Fimage.png?alt=media&#x26;token=418eb4dd-7206-4d56-ac33-c16c6eff6f49" alt=""></div>

Price as the function of ΔY:

<div align="center"><img src="https://976579298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ftor5sd7sW1BdSm5MKyoe%2Fuploads%2FAc7HYD3CpZvjNyS7SNDA%2Fimage.png?alt=media&#x26;token=890c6231-d729-45aa-9652-a370b1f9dd57" alt=""></div>

Note: if ΔX→0 and ΔY→0 (infinitely small trade amounts), then&#x20;

Pb → Pc and Ps → Pc and the spread equals 0.&#x20;

Pc = - dYdX = the derivative of the bonding curve function with a negative sign.

**The price functions have the following properties:**

* Continuous and monotone.
* Symmetric and reflective of the equality of assets X and Y. Thus, we can replace X↔Y, buy↔sell, and P ↔ 1P
* Practically, the pool assets will not be exhausted as:
  * Pb  → ∞ and  Y→ ∞ when X → Xc , for a buy trade;
  * Ps  → 0  and X→ ∞ when Y → Yc , for a sale trade;

The price functions determine the slippage for the buy and sell trades. When the trade quantities are relatively small in comparison to the pool total quantities (i.e. ΔX << Xc and ΔY << Yc ), the effective trade price will be very close to Pc.

However, as the trade quantity increases, the buy price rises for the buy trade and decreases for the sale trade, in comparison to the Oracle market price.

<br>
