Deep Dive: The Mathematics Behind the Unit of Liquidity

Deep Dive: The Mathematics Behind the Unit of Liquidity

A few months ago, we unveiled the Unit of Liquidity whitepaper, a comprehensive dive into the mathematical theory that powers the Catalyst Protocol. The Unit of Liquidity is Catalyst’s superpower. It allows Catalyst to be capital efficient, easy to use, secure and trust-minimised by design.

One of Catalyst's most remarkable feats lies in its ability to be readily available right from the launch of any new chain. This is no small achievement, and it's all thanks to the Unit of Liquidity. This dynamic feature takes the hassle out of cross-chain operations, granting users the ability to fluidly access and utilize their assets across different chains.

Picture a world where assets effortlessly traverse the boundaries of chains, all facilitated by this abstract representation of value. We call this vision Borderless Blockchain.

Today, we’ll go over the details of how the Unit of Liquidity is actually calculated and used in the protocol. Furthermore, we’ll present an illustrative example of a transaction flow, showcasing  the power of the Unit of Liquidity.

Catalyst Stack: A Primer

The Catalyst Protocol, like a finely tuned orchestra, harmonizes three essential components: vaults, math calculations, and the cross-chain messaging router.

Vaults serve as the guardians of assets, securely storing them within each blockchain.

The math calculations component acts as the conductor of the assets, calculating the Unit of Liquidity in order to facilitate the equivalent swapping of assets across chains.

The messaging router uses any arbitrary cross-chain communication mechanism (e.g., interoperability, L2 native bridges, SNARKs) in order to transport a message and verify the validity of a message being received. It ensures that messages are transported securely and their validity is attested.


An illustrative example of a transaction in the Catalyst Protocol:

Alice is an eager crypto enthusiast looking to exchange 'ETH' from Ethereum to 'SOL' on the Solana blockchain.

  1. Initiating the Swap: Alice commences the process by initiating a swap of 'ETH' for 'SOL' within Catalyst Protocol.
  2. Unit of Liquidity Generation: Catalyst Protocol first calculates Alice's ETH deposit into the Unit of Liquidity. This unit serves as her redemption receipt in order to access SOL on Solana.
  3. Crossing Chains: The Unit of Liquidity is sent from Ethereum to Solana, using any cross-chain messaging protocol.
  4. Asset Redemption: The Unit of Liquidity serves as the redemption mechanism for Alice’s desired SOL. The vault uses the Unit of Liquidity to ensure that Alice receives her fair portion of SOL, in relation to the amount of ETH that she deposited.

Redeeming Value: the Unit of Liquidity

In order to understand the Unit of Liquidity and how it allows for redemption of assets across different blockchains, we must first cover the foundations of conventional AMMs (Automated Market Makers) such as Uniswap v2. These platforms operate on a constant product market maker model, ensuring that the product of asset reserves remains invariant during trades.

A constant product market maker is a mathematical formula used in decentralized exchanges like Uniswap v2 to determine the exchange rate between two tokens in a liquidity pool. The formula maintains a constant product of the quantities of the two tokens in the pool. This constant product is referred to as the invariant.

In the context of Uniswap v2, the formula looks like this: Invariant = TokenA Quantity * TokenB Quantity

When a user swaps one token for another, the constant product formula ensures that the invariant remains unchanged. This leads to an automatic adjustment of the exchange rate as the quantities of the tokens change due to trades.
For example, if a user trades TokenA for TokenB, the quantity of TokenA in the pool decreases while the quantity of TokenB increases. The invariant remains the same, which leads to a shift in the exchange rate, benefiting the user who trades.

In the Catalyst Protocol, the same principle applies–but has been modified to natively support cross-chain swaps. Here, assets are not confined to one smart contract on one chain but rather inhabit separate smart contracts across separate chains – a concept scalable to N chains.

This conceptual separation means that now there are two price curves instead of one, which also allows for unique price curves for each asset.

Let's envisage a scenario where asset 'w' on one chain wants to be swapped into asset 'x' on another chain.

With ∆w added to the origin chain vault, the x-axis transitions from 'w1' to 'w2' and moves along the price curve P(w). We can calculate the integral of P(w) from 'w1' to 'w2', where the integral is a numerical representation of the area beneath the curve.

This integral is, in fact, the Unit of Liquidity.

The Catalyst Protocol then dispatches this Unit of Liquidity through any cross-chain message protocol. Upon arrival at the destination chain, the Catalyst smart contract imbues the local price curve P(x) with this newfound value.

Since assets are withdrawn from the destination vault, we need to move in the opposite direction of the price curve (i.e., up and to the left). Keeping the area underneath the curve constant, we can calculate the ∆x that needs to be withdrawn from the vault.

Conclusion

Integrals, the mathematical constructs that measure areas beneath curves, form the backbone of Catalyst Protocol's cross-chain liquidity mechanism. By enabling the calculation of the Unit of Liquidity, Catalyst ensures that assets can seamlessly flow between chains, transcending the barriers of individual ecosystems. This mathematical ingenuity empowers users with the ability to access assets across blockchains with unparalleled efficiency and security, defining a new frontier in the world of decentralized finance.

Want to learn more about the Unit of Liquidity? Check out the full whitepaper.