Liquidity

How MAYAChain facilitates continuous, incentivised liquidity.

Instead of limit-order books, MAYAChain uses continuous liquidity pools (CLP). The CLP is arguably one of the most important features of MAYAChain, with the following benefits:

  • Provides “always-on” liquidity to all assets in its system.

  • Allows users to trade assets at transparent, fair prices, without relying on centralised third-parties.

  • Functions as source of trustless on-chain price feeds for internal and external use.

  • Democratises arbitrage opportunities.

  • Allows pools prices to converge to true market prices, since the fee asymptotes to zero.

  • Collects fee revenue for liquidity providers in a fair way.

  • Responds to fluctuating demands of liquidity.

CLP Derivation

Element
Description
Element
Description

x

input amount

X

Input Balance

y

output amount

Y

Output Balance

Start with the fixed-product formula:

Eqn1:XY=KEqn 1: X*Y = K

Derive the raw "XYK" output:

Eqn2:yY=xx+Xy=xYx+XEqn 2: \frac{y}{Y} = \frac{x}{x+X} \rightarrow y= \frac{xY}{x+X}

Establish the basis of Value (the spot purchasing power of x in terms of Y ) and slip, the difference between the spot and the final realised y:

Eqn3:Valuey=xYXEqn 3: Value_y = \frac{xY}{X}
Eqn4:slip=ValueyyValuey=(xYX)yxYX=xx+XEqn 4: slip =\frac{Value_y - y}{Value_y} =\frac{( \frac{xY}{X})-y}{ \frac{xY}{X}} = \frac{x}{x+X}

Derive the slip-based fee:

Eqn5:fee=slipoutput=xx+XxYx+X=x2Y(x+X)2Eqn 5: fee = slip * output = \frac{x}{x+X} * \frac{xY}{x+X} = \frac{x^2Y}{(x+X)^2}

Deduct it from the output, to give the final CLP algorithm:

Eqn6:y=xYx+Xx2Y(x+X)2y=xYX(x+X)2Eqn 6: y = \frac{xY}{x+X} - \frac{x^2Y}{(x+X)^2} \rightarrow y= \frac{ xYX} {(x+X)^2 }

Comparing the two equations (Equation 2 & 6), it can be seen that the Base XYK is simply being multiplied by the inverse of Slip (ie, if slip is 1%, then the output is being multiplied by 99%).

Evolution of the CLP Model

Pegged Model

The simplest method to exchange assets is the pegged model, (1:1) where one asset is exchanged one for another. If there is a liquidity pool, then it can go insolvent, and there is no ability to dynamically price the assets, and no ability to intrinsically charge fees:

Eqn8:y=xEqn 8: y = x

Fixed Price Model

The fixed-sum model allows pricing to be built-in, but the pool can go insolvent (run out of money). The amount of assets exchanged is simply the spot price at any given time:

Eqn9:y=xYXEqn 9: y = \frac{xY}{X}

Fixed Product Model

The fixed-product model (Base XYK above), instead bonds the tokens together which prevents the pool ever going insolvent, as well as allowing dynamic pricing. However, there is no intrinsic fee collection:

Eqn10:y=xYx+XEqn 10: y= \frac{xY}{x+X}

Fixed-Rate Fee Model

The Fixed-Rate Fee Model adds a 30 Basis Point (0.003) (or less) fee to the model. This allows fee retention, but the fee is not liquidity-sensitive:

Eqn11:y=0.997xYx+XEqn 11: y= 0.997 * \frac{xY}{x+X}

Slip-based Fee Model (CLP)

The Slip-based Fee Model adds liquidity-sensitive fee to the model. This ensures the fee paid is commensurate to the demand of the pool's liquidity, and is the one MAYAChain uses. The fee equation is shown separate (12b), but it is actually embedded in 12a, so is not computed separately.

Eqn12a:y=xYX(x+X)2Eqn 12a: y= \frac{ xYX} {(x+X)^2 }
Eqn12b:fee=x2Y(x+X)2Eqn 12b: fee = \frac{x^2Y}{(x+X)^2}

The slip-based fee model breaks path-independence and incentivises traders to break up their trade in small amounts. For protocols that can't order trades (such as anything built on Ethereum), this causes issues because traders will compete with each other in Ethereum Block Space and pay fees to miners, instead of paying fees to the protocol. It is possible to build primitive trade ordering in an Ethereum Smart Contract in order to counter this and make traders compete with each other on trade size again. MAYAChain is able to order trades based on fee & slip size, known as the Swap Queue. This ensures fees collected are maximal and prevents low-value trades.

Benefits of the CLP Model

Assuming a working Swap Queue, the CLP Model has the following benefits:

  • The fee paid asymptotes to zero as demand subsides, so price delta between the pool price and reference market price can also go to zero.

  • Traders will compete for trade opportunities and pay maximally to liquidity providers.

  • The fee paid for any trade is responsive to the demand for liquidity by market-takers.

  • Prices inherit an "inertia" since large fast changes cause high fee revenue

  • Arbitrage opportunities are democratised as there is a diminishing return to arbitrage as the price approaches parity with reference

  • Traders are forced to consider the "time domain" (how impatient they want to be) for each trade.

The salient point is the last one - that a liquidity-sensitive fee penalises traders for being impatient. This is an important quality in markets, since it allows time for market-changing information to be propagated to all market participants, rather than a narrow few having an edge.

Virtual Depths

Balances of the pool (X and Y), are used as inputs for the CLP model. An amplification factor can be applied (to both, or either) in order to change the "weights" of the balances:

Element
Description

a

Input Balance Weight

b

Output Balance Weight

Eqn7:y=xYbXa(x+Xa)2Eqn 7: y= \frac{ xYbXa} {(x+Xa)^2 }

If a = b = 2 then the pool behaves as if the depth is twice as deep, the slip is thus half as much, and the price the swapper receives is better. This is akin to smoothing the bonding curve, but it does not affect pool solvency in any way. Virtual depths are currently not implemented

If a = 2, b = 1 then the Y asset will behave as though it is twice as deep as the X asset, or, that the pool is no longer 1:1 bonded. Instead the pool can be said to have 67:33 balance, where the liquidity providers are twice as exposed to one asset over the other.

Virtual Depths were initially applied to Synth Swaps using a multiplier of 2. It was intended that Synth Swaps would create 50% less slip and users pay 50% less fees. However, this was disabled after discovering that this would allow front-running. The multiplier is specified on /constants as:

"VirtualMultSynths": 2,

but currently overridden by a Mimir value of 1.

Calculating Pool Ownership

When a liquidity provider commits capital, the ownership % of the pool is calculated:

units=PrA+Ra+2rarA+Ra+2RAunits=P*\frac{rA+Ra+2ra}{rA+Ra+2RA}
  • units = newly created pool units for the liquidity provider

  • r = cacao deposited

  • a = asset deposited

  • R = total Cacao Balance (before deposit)

  • A = total Asset Balance (before deposit)

  • P = total Pool Units (before deposit)

The liquidity provider is allocated rewards proportional to their ownership of the pool. If they own 2% of the pool, they are allocated 2% of the pool's rewards.

Derivation

The new units are derived from the mean of adding new liquidity to both sides, multiplied by final total pool units.

units=P(r/R+a/A)2=P(Ra+rA)2RAunits = P * \frac{(r/R + a/A)}{2} = \frac {P(R a + r A)}{2 RA}

In terms of amounts before the deposit:

units=(P0+units)(R0+r)a+r(A0+a)2(R0+r)(A0+a)units = (P_0+units) * \frac{(R_0+r) a + r (A_0+a)}{2 (R_0+r)(A_0+a)}
=(P0+units)rA0+R0a+2ra2rA0+2R0a+2R0A0+2ra= (P_0+units) * \frac{rA_0+R_0a+2ra}{2rA_0+2R_0a+2R_0A_0+2ra}
units(2rA0+2R0a+2R0A0+2ra)=(P0+units)(rA0+R0a+2ra)units*(2rA_0+2R_0a+2R_0A_0+2ra)=(P_0+units)(rA_0+R_0a+2ra)
units(2rA0+2R0a+2R0A0+2ra(rA0+R0a+2ra))=P0(rA0+R0a+2ra)units*(2rA_0+2R_0a+2R_0A_0+2ra-(rA_0+R_0a+2ra))=P_0(rA_0+R_0a+2ra)
units(rA0+R0a+2R0A0)=P0(rA0+R0a+2ra)units*(rA_0+R_0a+2R_0A_0)=P_0(rA_0+R_0a+2ra)
units=P0rA0+R0a+2rarA0+R0a+2R0A0units=P_0*\frac{rA_0+R_0a+2ra}{rA_0+R_0a+2R_0A_0}

Impermanent Loss Protection

Impermanent Loss Protection ensures LPs always either make a profit, or leave with at break even after a minimum period of time (set at 100 days), and partially covered before that point. This should alleviate most of the concerns regarding become an LP.

MAYAChain tracks a member's deposit values. When the member goes to redeem, their loss (against their original deposit value) is calculated and is subsidised with CACAO from the reserve.

Impermanent Loss Protection is always recorded and calculated symmetrically.

There is a 100 day linear increase in the amount of coverage received, such that at 50 days, the member receives 50%, 90 days is 90% etc.

Element
Description
Element
Description

R0

CACAO Deposited

R1

CACAO to redeem

A0

Asset Deposited

A1

Asset to redeem

P1=R1A1\text{P1} = \frac{R1}{A1}

P1 is the pool ratio at withdrawal.

coverage=((A0P1)+R0)((A1P1)+R1)=>((A0R1/A1)+R0)(R1+R1)\text{coverage} = ((A0 * P1) + R0) - ((A1 * P1) + R1) => ((A0 * R1/A1) + R0) - (R1 + R1)

Deposit values are not the amounts the member deposited. They are the immediate symmetrical value of what the member deposited instead.

The coverage is then adjusted for the 100 or 400 day rule like so:

``blocksForFullProtection = 1440000 // 100 days

protectionProgress =(currentHeightheightLastAdded)/blocksForFullProtection\text{protectionProgress }= (currentHeight - heightLastAdded) / blocksForFullProtection
protection=(protectionProgresscoverage)\text{protection} = (protectionProgress * coverage)

Depending on the coverage due to CACAO over or under performance. Then the extra CACAO added into the member's liquidity position to issue them extra liquidity units. The member then redeems all their units, and they will realise extra CACAO and extra ASSET.

Since the protection amount is added asymmetrically, the protection will experience a small slip. This helps to prevent attack vectors.

Last updated