The Carbon DeFi versus Uniswap V3 Invariant Functions

Carbon DeFi makes use of the same geometric price sequences that have governed AMM behavior since its first realization in 2017. While Carbon DeFi is not an AMM, the majority of the underlying theory is indistinguishable from that of conventional “concentrated liquidity” AMM designs. However, rather than let the price curves be determined by one and the same invariant curve (which, traditionally described two different token balances), instead, each token balance is given its own implicit curve (i.e. one “bonding curve” per token). This allows for arbitrary separation of bidding and asking prices characterized by irreversible token swaps, from which emerges a trading “strategy” – the core object of Carbon DeFi.

Naming Conventions and Nomenclature

The implicit curves of the invariant function used by Carbon Defi adhere to the following conventions:

  • Assume the implicit curves are drawn on a Cartesian plane.

  • The available token balance is always depicted on the y axis, whereas the x axis does not refer to a token balance.

  • Therefore, during a token swap, the tokens sent from the swapper to the contract is always Δx, and the tokens sent from the contract to the swapper is always Δy.

  • The marginal price quote, -∂y/∂x, refers to the rate of y tokens purchased during a swap relative to the x tokens sold by the swapper; therefore large -∂y/∂x values represent a higher valuation of the x token relative to the y token and small -∂y/∂x values represent a lower valuation of the x token relative to the y token.

  • Carbon DeFi’s “liquidity providers” choose two separate price quotes or price quote ranges: one supports trades of TKN1 → TKN2, and the other supports trades TKN2 → TKN1. Since both tokens are featured independently on their own y axis, and owing to the swap conventions described above, both price quotes are expressed in the form - ∂y/∂x.

  • Each token’s implicit real curve is parametrized by three (3) terms:

    1. 𝒂

      ▪ Defined as the difference between the square roots of the marginal exchange rates at the 𝑦-intercept, and the 𝑥-intercept.

      𝑎=𝑃high𝑃low=(𝜕𝑦𝜕𝑥𝑥=0)12(𝜕𝑦𝜕𝑥𝑦=0)12\normalsize 𝑎 = \sqrt{𝑃_{high}} − \sqrt{𝑃_{low}} = \left( -\frac{𝜕𝑦}{𝜕𝑥}|_{𝑥=0}\right)^\frac{1}{2} − \left(− \frac{𝜕𝑦}{𝜕𝑥}|_{𝑦=0}\right)^\frac{1}{2}

    2. 𝒃

      ▪ Defined as the square root of the marginal exchange rate at the 𝑥- intercept, only.

      b=𝑃low=(𝜕𝑦𝜕𝑥y=0)12\normalsize b = \sqrt{𝑃_{low}} = \left( -\frac{𝜕𝑦}{𝜕𝑥}|_{y=0}\right)^\frac{1}{2}

    3. 𝒛

      ▪ Defined as the value of the 𝑦-intercept.

      𝑧=yx=0\normalsize 𝑧 = y|_{x=0}

The Carbon DeFi versus Uniswap V3 Invariant Functions

The Carbon DeFi invariant function can be written as:

(x+za(a+b))(y+zba)=z2a2\Large \left(x + \textcolor{#ffa2a1}{ \frac{z}{a \cdot (a+b)}}\right) \cdot \left( y + \textcolor{#dc70fa}{ \frac{z \cdot b}{a}}\right) = \textcolor{#90f597}{\frac{z^2}{a^2}}

Which has the same structure as the familiar Uniswap V3 invariant function, as written in its whitepaper:

(x+LPhigh)(y+LPlow)=L2\Large \left( x + \textcolor{#ffa2a1}{\frac{L}{\sqrt{P_{high}}}}\right) \cdot \left( y + \textcolor{#dc70fa}{L \cdot \sqrt{P_{low}}}\right) = \textcolor{#90f597}{L^2}

Both Carbon DeFi’s and Uniswap V3’s invariant functions refer to the same underlying mathematical and geometric objects, and the terms highlighted above are equivalent to each other.

za(a+b)=LPhigh\Large \textcolor{#ffa2a1}{\frac{z}{a \cdot (a+b)}} = \textcolor{#ffa2a1}{\frac{L}{\sqrt{P_{high}}}}
zba=LPlow\Large \textcolor{#dc70fa}{\frac{z \cdot b}{a}} = \textcolor{#dc70fa}{L \cdot \sqrt{P_{low}}}
z2a2=L2\Large \textcolor{#90f597}{\frac{z^2}{a^2}} = \textcolor{#90f597}{L^2}

For further assistance, please join the Bancor Developer telegram group

Last updated