Page cover image

Deep Dive

Understanding price action from first principles

Constant Product

We start by defining a simple constant product market, commonly used to trade tokens. The market is composed of two reserves (R0,R1)(R_0, R_1) of token0token0 and token1token1 respectively, and a constraint:

(R0+x)⋅(R1−y)=R0⋅R1(R_0 + x) \cdot (R_1 - y) = R_0 ⋅ R_1

When xx amount of token0token0 is inputted to the market, yy token1token1 comes out, constrained by the product of the reserves.

solving for y gives us the amount out:

y=R1−R0⋅R1R0+xy = R_1 - \frac{R_0 \cdot R_1}{R_0 + x}

From this, we can derive the market trading function κ:(R0,R1,x)−>(R0′,R1′)\kappa : (R_0, R_1, x) -> (R_0′, R_1′):

R0′=R0+xR_0′ = R_0 + x
R1′=R0⋅R1R0+xR_1′ = \frac{R_0 \cdot R_1}{R_0 + x}

that describes market dynamics when traded.

KIRU Bonding Curve

We instantiate token0=token0 = ETH and token1=token1 = KIRU.

We introduce a scale parameter α:[0,1]α: [0, 1]

α(t)=1−(α(0)∗R1(t)R1(0))α(t) = 1 - (α(0) * \frac{R_1(t)}{R_1(0)})

The parameter decrease in intensity as KIRU reserves deplete to ensure gradual smoothing of the scaling effect.

We can then introduce the trading function Γ+:(R0,R1,α,x)−>(R0′,R1′)Γ^+ : (R_0, R_1, α, x) -> (R_0′, R_1′) for buy orders, defined as:

(αR0′,αR1′)=κ(α⋅R0,α⋅R1,x)(αR_0′, αR_1′) = \kappa(α \cdot R_0, α \cdot R_1, x)
R0′=R0+xR_0′ = R_0 + x
R1′=αR1′αR0′⋅R0′R_1′ = \frac{αR_1′}{αR_0′} ⋅ R_0′

The new KIRU reserve is computed using the virtual reserves ratio, and used to compute the amount out yy:

y=R1−αR1′y = R_1 - \alpha R_1\prime

The excess KIRU coming from the difference between the virtual effective price and the effective price is then burned.

The transition function for sell orders stay the same, enjoying full liquidity when exiting.

Spot price

We introduce the spot price formula:

spot=R0/R1spot = R_0 / R_1

Applying it to the trading functions.

For κ\kappa:

spotκ=(R0+x)2R0⋅R1spot^\kappa = \dfrac{ (R_0 + x)^2 }{ R_0 \cdot R_1 }

and Γ\Gamma:

spotΓ=(αR0+x)2α2R0⋅R1spot^\Gamma = \dfrac{ ( \alpha R_0 + x )^2 }{ \alpha^2 R_0 \cdot R_1}

To study price action between trading functions, we simplify spotΓspotκ\frac{spot\Gamma}{spot\kappa}:

(αR0+xαR0+αx)2\left( \frac{ \alpha R_0 + x }{ \alpha R_0 + \alpha x } \right)^2

Expressing the difference of the two terms in terms of xx and α\alpha:

Numerator−Denominator=(αR0+x)−(αR0+αx)=x−αx=x(1−α)\begin{align*} \text{Numerator} - \text{Denominator} &= ( \alpha R_0 + x ) - ( \alpha R_0 + \alpha x ) \\ &= x - \alpha x \\ &= x ( 1 - \alpha ) \end{align*}

We notice that the difference increases as α\alpha decreases from 1 to 0.

Denominator−Numerator=(αR0+αx)−(αR0+x)=αx−x=x(α−1)\begin{align*} \text{Denominator} - \text{Numerator} &= ( \alpha R_0 + \alpha x ) - ( \alpha R_0 + x ) \\ &= \alpha x - x \\ &= x ( \alpha - 1 ) \end{align*}

Since x>0x > 0 and α≤1\alpha \le 1, the ratio is always positive, proving that over equal volume, Γ+\Gamma^+ implies a greater price increase than the classical constant-product, scaled by α\alpha.

Last updated