Comment on page
Hybrid Liquidity Engine for spot markets
Powered by the Hybrid Liquidity Engine, Carbon is the first protocol to combine AMMs with orderbooks on spot markets. This means that the liquidity pool module is able to interoperate with the orderbooks to display AMM liquidity on the orderbook DEX in real-time.
As such, trading of spot markets is supported by liquidity pools. Liquidity providers (LPs) can earn from fees from market maker rebates, spread, and protocol incentives.
An orderbook is available for each coin pair. Users can submit both limit and market orders and transparently observe existing limit orders on orderbooks. The orderbook helps to facilitate a good onboarding process for users who are familiar with orderbooks on CEXs.
Next, liquidity pools offer permissionless liquidity via smart contracts, bypassing the need for intermediaries.
When a user is swapping tokens, they are depositing tokens into the pool to remove a market rate amount of the other token. The effective price for the swap is determined by the ratio of tokens in the pool.
For a token pair, a liquidity pool can be created by anyone on Carbon. By simply depositing a pair of coins (in corresponding ratios) into a pool, anyone can become a liquidity provider.
Let us imagine trading ETH tokens for SWTH tokens on Demex. After swapping the tokens, the algorithm calculates how much the trade impacts the liquidity pool’s reserves - after which a price quote is given.
After approving the transaction, the AMM sends SWTH tokens into the ETH-SWTH pool. Finally, it sends the quoted amount of ETH from the pool to the user’s wallet.
To buy ETH (x) on Demex, users need to add SWTH (y) tokens to the pool. Note that k demands that the amount of liquidity remains constant. Therefore, by adding SWTH tokens users increase one side of the pool and decrease the other (removing ETH).
The pool price is defined as the ratio of the number of the quote coins and the number of the base coins in the pool. For the coin pair
A-B, the pool price is the number of coin
Bdivided by the number of coin
Ain the pool.
In our example, the algorithm divides the pool's total liquidity by the new amount of SWTH in the pool, then divides that by the new amount of ETH in the pool so that (k / y) / x = price. This is how the protocol determines the price paid for ETH (and other tokens), which will increase the more ETH is bought from the pool.
Under the hybrid model, users can play several roles:
- Liquidity provider
As illustrated above, liquidity in the pool is automatically converted to orders to be submitted to the orderbook.
The AMM provided by the liquidity pool coexists with traditional market makers. This facilitates greater capital efficiency for traders who can enjoy the effectively abundant liquidity on the orderbook.
This allows liquidity to be used as efficiently as possible by the AMM so that LP earnings are maximized.