This monorepo contains all Catalyst implementations
Catalyst is an implementation of the Unit of Liquidity AMM design. A design which used independent pricing to asynchronously price assets using shared liquidity, supporting both volatile assets and stable assets.
Each implementation is contained within its own folder.
- /evm : Solidity implementation targeting the Ethereum Virtual Machine.
- /rust-common : Contains depreciated code
- /simulator : Simulation of the Catalyst logic.
- /solana : Rust implementation targeting the Solana Virtual Machine.
The EVM implementation is used as a reference implementation.
For an indepth description of how to price assets, read Unit of Liquidity
. The below section contains notable equations.
Let
Where
This implies that the full swap from a token
Notice that even though the full swap is written as a single equation, it can be evaluated in 2 independent slices (based on the previous equation).
Catalyst defines 2 price curves to serve both demand for volatile tokens and tokens with a stable value.
Volatile:
Amplification:
Marginal Price: If someone were to buy/sell an infinitesimal in the vault. the marginal price is the price they would pay. The marginal price can generally be derived in 2 + 1 ways:
sendAsset: The first swap of a Catalyst swap. It is independent of the state of the second leg of the transaction. Within a vault
receiveAsset: The last (and second) leg of a Catalyst swap. It is completely independent of the state of the first leg of the transaction. It requires
LocalSwap: A combination of sendAsset and receiveAsset executed atomically, often on a single chain.
Invariant: A measure used to measure the vault value. Specific to the invariant measure, is that it is constant whenever a swap is completed. If a vault implements a swap fee, the measure increases as fees accumulate in the vault. The invariant is not invariant to deposits or withdrawals. The invariants can continuously be examined if the number of emitted Units is kept track of. In the below equations, this is represented as
Using the Catalyst Equation with the price curves, the mathematical swap equations can be derived.
-
Marginal price:
$\lim_{x \to 0} y_j/x_i = \frac{j}{i} \frac{W_i}{W_j}$ -
SwapToUnits:
$U = W_i \cdot \log\left(\frac{i_t+x_i}{i_t}\right)$ -
SwapFromUnits:
$y_j = j_t \cdot \left(1-\exp\left(-\frac{U}{W_j}\right)\right)$ -
Invariant:
$K = \sum_{i \in {\alpha, \beta, \dots}} \ln(i_t) \cdot W_i + \sum U$
-
Marginal price:
$\lim_{x \to 0} y_j/x_i = \frac{\left(i_t W_i\right)^\theta}{\left(j_t W_j\right)^\theta} \frac{W_j}{W_i}$ -
SwapToUnits:
$U = \left((i_t \cdot W_i + x_i \cdot W_i)^{1-\theta} - \left(i_t \cdot W_i \right)^{1-\theta} \right)$ -
SwapFromUnits:
$y_j = j_t \cdot \left(1 -\left(\frac{\left(j_t \cdot W_j\right)^{1-\theta} - U }{\left(j_t \cdot W_j\right)^{1-\theta}}\right)^{\frac{1}{1-\theta}}\right)$ -
Invariant:
$K = \sum_{i \in {\alpha, \beta, \dots}} i^{1-\theta} W_i^{1-\theta} + \sum U$