Version: V1

# Programmable Pricing Curve

Programmable pricing curves try to improve capital efficiency of the Uniswap model. The curves are still a constant product, but of virtual balances instead of real balances. Thanks to the virtual balances, which are amplified significantly from real balances, the DMM pools can achieve moderate spread and slippage rates compared to the Uniswap model given the same capital.

We first define $x_0$ and $y_0$ to be the liquidity providers’ initial contributions to the pool, such that $x_0 \cdot y_0 = k$. This is the familiar simple constant-product function.

We now introduce what is known as the amplification factor a and a > 1. As its name suggests, it amplifies the real balances to virtual balances. Hence, we can define virtual balances $x'_0$ and $y'_0$, where $x'_0 = x_0 \cdot a$ and $y'_0 = y_0 \cdot a$.

The pool with programmable pricing curve model will maintain a constant product of these virtual balances by using the new inventory function:

$x' · y' = k'$

The constant $k'$ can be derived from $k$ as follows:

$x' \cdot y' = k' \\ x'_0 \cdot y'_0 = k' \\ (x_0 \cdot a) \cdot (y_0 \cdot a) = k' \\ k' = k \cdot a^2 \\ x' \cdot y' = k \cdot a^2$

We see that users benefit from lower spread and slippage when the pools use the new pricing curve. However, this comes at the expense of the price range no longer being unbounded, but being restricted between a fixed price range.

Let us take a pool with amplifcation factor 2 as an example, where the virtual balances are double the real balances in the original constant-product model. The price range support for this is from $\cfrac{P_0}{4}$ to $4P_0$. In other words, this particular pool can support 0.25x to 4x the initial price set. Should this price range be exceeded, it would result in the pool being depleted of one of the tokens.

The inventory curves of Uniswap, Curve and programmable pricing curve are visualized in figure below. Inventory curves of Uniswap (red), Curve (green) and programmable pricing curve (blue)

### Price ranges in the Amplification model#

To illustrate mathematically:

Let

• $P$ be the price function of $X$ against $Y$
•  Initial price, $P_0 = \cfrac{y_0}{x_0}$
• $P_{min}, P_{max}$, the minimal and maximal price supported by the programmable pricing curve respectively

Therefore, to compute the minimal and maximal price:

$P_{max} = P_0 \cdot (\cfrac{a}{a-1})^2 \\ P_{min} = P_0 \cdot (\cfrac{a-1}{a})^2$

The pool will run out of token $X$ or $Y$ when the real balances $x_0$ and $y_0$ are zero respectively.

In summary, we see that users benefit from lower spread and slippage when the pools use the new pricing curve. However, this comes at the expense of the price range no longer being unbounded, but being restricted between $P_{min}$ and $P_{max}$. Functions of price ratio $P_{min}$ (red), 1 (blue), and $P_{max}$ (black) Inventory curves of two reserves: Uniswap V2 swap model (green), Amplification model (violet)