Skip to main content

Omnipool Design

The Hydration Omnipool is a novel type of AMM which concentrates all liquidity in a single trading pool, thus unlocking an array of efficiencies. This doc contains a mathematical specification of the mechanics which power the Omnipool.

The Omnipool

Hub token

The Omnipool uses LRNA as a "hub" token through which all trades are routed, avoiding the segmentation of liquidity inherent to AMMs which require LPs to provide liquidity for a pair of tokens. Both transaction fees and partial impermanent loss mitigation are paid out in LRNA.

A note on notation

Throughout this page, we will refer to the change in some amount AA as ΔA\Delta A. When AA is a pool variable (e.g. the quantity of some asset in the pool), we adopt the convention that ΔA\Delta A is negative if the pool variable is decreasing (e.g. some amount of the asset is leaving the pool) and ΔA\Delta A is positive if the pool variable is increasing (e.g. some amount of the asset is entering the pool). In particular, note that this means when we consider a swap of ΔA\Delta A of one asset for ΔB\Delta B of another asset, one of these will be negative.

A user variable ss meanwhile will have the sign convention that flows to the user are denoted by positive Δs\Delta s while flows away from the user are denoted by negative Δs\Delta s. In particular, for a token transfer to/from the pool for some token TT, we will have Δt=ΔT\Delta t = -\Delta T.

We will also adopt the notational convention that A+=A+ΔAA^+ = A + \Delta A.

Swap Execution

In version 1, the prices behave as though each TKN1/LRNA pool is a constant product CFMM, although other CFMMs continue to be under investigation.

Let Q1Q_1 be the quantity of LRNA in the TKN1 pool and T1T_1 be the quantity of TKN1. Suppose a trader stipulates they wish to sell ΔT1\Delta T_1 of TKN1 for TKN2. Then Q1T1=Q1+T1+Q_1 T_1 = Q_1^+ T_1^+, so with asset fee fAf_A and protocol/LRNA fee fPf_P, we have

ΔQ1=Q1ΔT1T1+ΔQ2=ΔQ1(1fP)ΔT2=T2ΔQ2Q2+(1fA)\Delta Q_1 = Q_1 \frac{-\Delta T_1}{T_1^+}\\ \Delta Q_2 = -\Delta Q_1 (1 - f_P)\\ \Delta T_2 = T_2 \frac{-\Delta Q_2}{Q_2^+} (1 - f_A)\\

The LRNA or "protocol" fee is fPΔQ1- f_P \Delta Q_1 (which is positive since ΔQ1\Delta Q_1 is negative) and the asset fee is fAT2ΔQ2Q2+- f_A T_2 \frac{-\Delta Q_2}{Q_2^+}.

Providing Liquidity to Omnipool

Liquidity providers (LPs) may contribute a single asset, and in return receive a share of the pool of that asset. When the LP removes liquidity, they may receive both the asset they provided and LRNA.

Single-asset liquidity providers for some TKN cannot always be given only the token they contributed, because if the price of TKN has gone up and substantial amounts of TKN have left the pool, LPs of TKN are splitting a much smaller pot. The protocol, meanwhile, has a much larger amount of LRNA that has been traded in for TKN. Instead of simply allowing LPs to take the loss, the protocol splits the matched pool with the LPs. If the price of TKN goes up (via LRNA being traded into the pool for TKN), the LPs are entitled to some of that LRNA. On the other hand, if the price of TKN goes down (via TKN being sold to the pool for LRNA), the protocol is entitled to some TKN.

Let pp be the current price of TKN, p0p_0 the price when an LP initially provided liquidity, Δs\Delta s the number of shares the LP wishes to withdraw, BB the number of TKN shares owned by the protocol.

Note that since shares are burned when liquidity is removed, Δs<0\Delta s < 0.

If the price of TKN has gone down (p<p0p < p_0), the LP will be withdrawing only TKN (no LRNA). The protocol will take control of some TKN shares from them, while some shares will be burned.

We first calculate the change to the protocol share ownership of TKN:

ΔB=max(p0pp+p0Δs,0)\Delta B = max\left(-\frac{p_0 - p}{p + p_0} \Delta s, 0\right)

Note that if p<p0p < p_0 (the price of TKN has gone down), ΔB\Delta B is positive, meaning that the protocol is claiming some of the Δs\Delta s shares from the LP. If p>p0p > p0, the protocol claims no asset shares from the LP.

Next, we find the number of shares to burn:

ΔS=Δs+ΔB\Delta S = \Delta s + \Delta B

We can then calculate the total amount of TKN the LP receives, which is simply proportional:

ΔT=TΔSSΔt=ΔT\Delta T = T \frac{\Delta S}{S}\\ \Delta t = -\Delta T

If p>p0p > p_0, lots of LRNA was traded into the Omnipool for TKN, so the protocol has extra LRNA go give the LP. Specifically,

Δq=p(2pp+p0ΔsST+Δt)ΔQ=QΔTT\Delta q = - p \left(\frac{2p}{p + p0} \frac{\Delta s}{S} T + \Delta t\right)\\ \Delta Q = Q \frac{\Delta T}{T}

Note that since ΔQΔq\Delta Q \neq -\Delta q, the LRNA that is not distributed to the LP who is withdrawing liquidity is burned by the protocol.

Impermanent Loss of Single-Asset Liquidity Provider

Given the mechanisms described above, the "impermanent loss" of a single asset LP is

2pp0p0+p1\frac{2\sqrt{p p_0}}{p_0 + p} - 1

The single-asset LP has sensitivity only to the TKN/LRNA price, not to prices of other tokens in the Omnipool (except indirectly via LRNA).